[PyQt] mouse pressed event with qt 4.5
Thomas Espenhain
thomas.espenhain at googlemail.com
Tue Mar 17 23:29:21 GMT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Andreas,
thanks for your answer and sorry for the missing example .. here it
comes:
import sys
from PyQt4 import QtCore, QtGui
app = QtGui.QApplication(sys.argv)
class Example(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self, parent)
self.firstPage = QtGui.QWidget()
self.firstPage.setLayout(QtGui.QHBoxLayout())
self.secondPage = QtGui.QWidget()
self.secondPage.setLayout(QtGui.QHBoxLayout())
btn1 = QtGui.QPushButton('btn1')
self.connect(btn1, QtCore.SIGNAL('pressed()'), self.on_btn1_pressed)
self.firstPage.layout().addWidget(btn1)
btn2 = QtGui.QPushButton('btn2')
self.connect(btn2, QtCore.SIGNAL('pressed()'), self.on_btn2_pressed)
self.secondPage.layout().addWidget(btn2)
self.stw = QtGui.QStackedWidget()
self.stw.addWidget(self.firstPage)
self.stw.addWidget(self.secondPage)
self.setLayout(QtGui.QHBoxLayout())
self.layout().addWidget(self.stw)
def on_btn1_pressed(self):
print 'btn1 pressed'
self.stw.setCurrentWidget(self.secondPage)
def on_btn2_pressed(self):
print 'btn2 pressed'
if __name__ == '__main__':
main = Example()
main.show()
sys.exit(app.exec_())
works with qt-4.4.3 and pyqt-4.4.4
with qt-4.5.0 and pyqt-4.4.4 the on_btn2_pressed method is called
directly after btn1 pressed
Thomas
Am 17.03.2009 um 20:28 schrieb Andreas Pakulat:
> On 17.03.09 12:43:28, Thomas Espenhain wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Hi,
>> I have a strange behavior with the mouse pressed event with pyqt4
>> with
>> qt-4.5
>> Following situation:
>> - - a stacked widget with 2 pages
>> - - every page has a button placed at same position
>> - - button1 on page 1 makes page 2 active
>> - - button2 on page 2 makes something else
>> And here is the problem:
>> If I press button1, the second page gets active but also the button2
>> pressed-method is executing right now!
>> The buttons are inherited from qpushbutton. I overwrote the
>> mousePressedEvent to find out whether the method is also called on
>> button2 or not. In my suprise the methode is called one time only -
>> from
>> button1!
>>
>> The same behavior if pressed-method of button A deletes itself and
>> makes
>> another button visible at position of button A.
>>
>> With qt4.4 it works correct.
>> Pyqt is version 4.4.4 in both cases
>>
>> Can someone confirm the behavior?
>
> Where's the minimal executable example that reproduces this? A wild
> guess I
> could make: The buttons are both childs of the stackwidget itself
> and not
> the pages and are simply put at the right position via move() or
> some such
> - instead of a layout. But of course thats just a guess without
> seeing the
> actual code.
>
> Andreas
>
> --
> The time is right to make new friends.
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)
iD8DBQFJwDJRM34iAr5ELxcRAux8AJ9Du4w9uQAGsf7Jhr5rMTbcNWa0EgCeM0bA
JvlNVzdClGZLveGSusHUr8o=
=uMA7
-----END PGP SIGNATURE-----
More information about the PyQt
mailing list