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

2013-08-29 Thread Sarah Mount
On Tue, Aug 27, 2013 at 9:44 PM, David Boddie da...@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
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Scroll QTableView beyond last column/row

2013-08-29 Thread Mark Mordeca
Thanks,  this is pretty much provides the behaviour I want, however there
is one oddity with it.  It allows me to successfully scroll past the last
row, but at a certain point I will be able to move the scroll bar to the
very end which causes the entire table to “snap” back to the bottom.  Did
you find a way to avoid this?



Appreciate your help.



*From:* Paul Du Bois [mailto:dub...@doublefine.com]
*Sent:* August-28-13 4:34 PM
*To:* Mark Mordeca
*Cc:* pyqt@riverbankcomputing.com
*Subject:* Re: [PyQt] Scroll QTableView beyond last column/row



I do this:



# somewhere in init

self._last_vsb_height = None


self.verticalScrollBar().rangeChanged[int,int].connect(self._on_range_changed)



def _on_range_changed(self, min, max):

# Try to prevent infinite recursion

# Count is in rows

if max != self._last_vsb_height:

sender = self.verticalScrollBar()

self._last_vsb_height = max + 20

sender.setRange(min, self._last_vsb_height)





On Wed, Aug 28, 2013 at 12:28 PM, Mark Mordeca mark.mord...@prosensus.ca
wrote:

Greetings,



I have a simple QTableView connected to an QAbstractTableModel.  For the
purposes of my question, let’s assume that these are the most basic you can
have in order to get a table with data in it.



Default behaviour is that you can scroll the table so that the last
column/row becomes visible, but no further.  I would like to be able to
scroll the table *past* the last row/column, i.e. I want to be able to
continue to click right on the horizontal scroll bar even though I have
reached the last column, thereby making the last column continue to shift
left in the table revealing “empty space” in the TableView.



I have been unsuccessful in trying to find a way and hoped that someone
here had a way to do this or a suggestion as to how.



Thank you,

Mark




___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] return value from QGraphicsItem::itemChange is not handled properly.

2013-08-29 Thread Yann Le Hir
Hi,

I'm having an issue with QGraphicsItem::itemChange.

Here is the test program :

import PyQt5.Qt  as qt

class Node( qt.QGraphicsRectItem ) :
def __init__( self , sector ) :
super( Node , self ).__init__( sector )

def itemChange( self , change , v ) :
res = super( Node , self ).itemChange( change , v )
print itemChange return value : ,res
return res

b = qt.QGraphicsLineItem()
c = qt.QGraphicsLineItem()
a = Node(b)
print a.parentItem(),b
a.setParentItem(c)
print a.parentItem(), c


I get this output :
PyQt5.QtWidgets.QGraphicsLineItem object at 0x8f9f194 
PyQt5.QtWidgets.QGraphicsLineItem object at 0x8f9f194
itemChange return value :  PyQt5.QtWidgets.QGraphicsLineItem object at 
0x8f9f1dc
itemChange return value :  PyQt5.QtWidgets.QGraphicsLineItem object at 
0x8f9f1dc
None PyQt5.QtWidgets.QGraphicsLineItem object at 0x8f9f1dc

If I remove itemChange, I get this output :
PyQt5.QtWidgets.QGraphicsLineItem object at 0xf2e6814c 
PyQt5.QtWidgets.QGraphicsLineItem object at 0xf2e6814c
PyQt5.QtWidgets.QGraphicsLineItem object at 0xf2e68194 
PyQt5.QtWidgets.QGraphicsLineItem object at 0xf2e68194

I'm using PyQt-5.0, Sip 4.14.7 and Qt 5.1.0
I tried with PyQt-5.0.1, sip 4.15.1 and Qt 5.1.0 without change.

I digged into this, basically when setParentItem is called itemChange is called 
on this item and use the return value of itemChange to set the parent.
In C itemChange returns a QVariant, which must be casted as a QGraphicsItem to 
be set as a parent.
This took me to the Chimera::parse_py_type function. Apparently, someone (QT?) 
registers QGraphicsItem as a QMetaType, but not QGraphicsLineItem.

If I replace :
_metatype = QMetaType::type(_name.constData());
By :
if(strcmp(_name.constData(),QGraphicsLineItem*)==0)
_metatype = QMetaType::type(QGraphicsItem*);
else
_metatype = QMetaType::type(_name.constData());

(I know how bad this is, but it's for demonstration purpose.)

The output of the test program is then :
PyQt5.QtWidgets.QGraphicsLineItem object at 0x89ba194 
PyQt5.QtWidgets.QGraphicsLineItem object at 0x89ba194
itemChange return value :  PyQt5.QtWidgets.QGraphicsLineItem object at 
0x89ba1dc
itemChange return value :  PyQt5.QtWidgets.QGraphicsLineItem object at 
0x89ba1dc
PyQt5.QtWidgets.QGraphicsLineItem object at 0x89ba1dc 
PyQt5.QtWidgets.QGraphicsLineItem object at 0x89ba1dc

Any ideas on how to fix this properly ?

Regards,
Yann.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt