[PyQt] PyQt4 question about type-to-select in numeric drop-down lists

Sarah Mount mount.sarah at gmail.com
Thu Aug 29 10:48:46 BST 2013


On Tue, Aug 27, 2013 at 9:44 PM, David Boddie <david at boddie.org.uk> wrote:

> On Tue Aug 27 15:53:59 BST 2013, Sarah Mount wrote:
>
> > sorry if this is a bit of a n00b question, but hopefully someone can
> > clarify a misunderstanding for me. I am working with some colleagues on a
> > Python2.x PyQt4 project and the GUI for this software has several
> drop-down
> > lists where each entry in the list is an integer, in numerical order. We
> > have had a (reproducible) bug report about these.
>
> No problem. Sometimes what seems to be the simplest things can have
> surprising behaviour.
>
>
Indeed :)


> > When a user clicks on the drop-down and types a number, the drop-down
> > scrolls to select that number. So, [contrived example] if the drop-down
> > contains entries 0-1000 and the user types 23, the drop-down scrolls to
> > reveal 23 (if necessary) and selects that entry on the list. So far, so
> > standard.
> >
> > If the user selects a number with repeated digits, i.e. any multiple of
> 11
> > (in reality only tested on numbers <100) the wrong number is selected.
> For
> > example, if I open a drop-down and type "77" "70" gets selected. Is this
> > some obvious bug in the way we have configured our GUI or have I
> > misunderstood something really basic?
>
> No, I think it's a bug in Qt, and probably in QAbstractItemView because
> that's what is providing the underlying list logic in the drop-down menu.
> The behaviour seems to be that the string used to search the data is
> checked
> to see if it is simply the same first character repeated throughout the
> string (e.g., "aaa" or "333") and handled specially. This seems to
> completely
> break the regular behaviour: if you try "77", it won't work, but "776" will
> cause it to navigate to the correct item.
>
>
That makes sense. Is there an issue tracker I can submit this to?



> If anyone wants to sanity check my reasoning, I think the problem is in
> QAbstractItemView::keyboardSearch().
>
> I can't immediately suggest a workaround. My instinct would be to use a
> completer to influence the way QComboBox finds items but I don't know if
> that will help, especially when the drop-down is open.
>
>
I think in reality it is not a huge issue for users, although it's not
ideal. I would guess that most integer input is probably not appropriately
done with drop-downs!

Thanks,

Sarah

-- 
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20130829/ab26aba7/attachment.html>


More information about the PyQt mailing list