[PyQt] QSpinBox: behavior on Linux

Mads Ipsen mpi at comxnet.dk
Thu Jun 4 18:19:42 BST 2009


TP wrote:
> Hi everybody,
>
> I have detected a strange behavior on Linux with QSpinBox (try the code
> example below): when the "valueChanged( int )" signal is connected to a 
> function that takes some time to execute, sometimes the "up" and "down"
> clickable buttons of the QSpinBox increment and decrement its value by 2 or
> more, instead of 1. Whereas on Windows it works correctly. Could you try
> under Linux and confirm the strange behavior?
>
> I have another question: why does the value of the spinbox change only after
> the function has been executed? How to force the spinbox value to change
> immediately, and call the function to be executed AFTER?
>
> My version of PyQt: PyQt-x11-gpl-4.4.4
> My version of Qt: 4.4.0.
>
> Thanks
>
> ##########
> from PyQt4.QtCore import *
> from PyQt4.QtGui import *
> import sys, time
>
> app = QApplication( sys.argv )
> dialog = QDialog( )
> # dialog.setBackgroundRole( 9 )
> dialog.resize( 750, 550 )
>
> def wait_a_moment():
>     # pass
>
>     time.sleep( 0.5 )
>
>
> spinbox = QSpinBox( dialog )
>
> QObject.connect( spinbox
>         , SIGNAL( "valueChanged ( int )" )
>         , wait_a_moment )
>
> vboxlayout = QVBoxLayout( dialog )
> dialog.setLayout( vboxlayout )
> dialog.show()
>
> app.exec_()
> ##########
>
>   

Yes, this is correct, and I posted a similar question regarding this 
behavior observed under Linux. The most peculiar thing, is that it works 
correctly if you select the QLineEdit of the QSpinBox and press the up 
and down arrows on the keyboard.

The problem is, however, fixed in Qt 4.5.1!

Best regards,

Mads


More information about the PyQt mailing list