Tommytrojan
28th April 2006, 18:10
I ran into a problem with poping up a dialog window (a simple message box will do) while the application is moved (by the user using the mouse and dragging the application).
I narrowed it down to a few lines of code (attached, I'm using PyQt but I'm sure this will be the same for the C++ interface).
Basically I pop up a simple dialog in a timer event. If the application is just sitting there everything is fine and the dialog pops up and the user can acknowledge it just fine. However, if the user holds down the mouse button on the application caption (starting of a drag operation) while the timer expires and the dialog pops up the entire application is frozen. Not only the application but all applications on the desktop are frozen. It seems like the mouse is captured and not released properly. I can close the dialog by pushing the ESC button. This will also allow to interact with all other applications.
I'm using Windows XP, Qt 3.3.1. I tested with Qt 2.3.0 and this does not occur, mostly due to the fact that the timer stops while dragging the window and therefore the dialog never pops up while the mouse is held down on the application.
Any solutions would be highly appreciated.
Thanks,
Tommy
import sys
import qt
class TMainWindow(qt.QMainWindow):
def __init__(self, *args):
qt.QMainWindow.__init__(self, *args)
self.label = qt.QLabel(self)
self.c=0
self.oTimer = qt.QTimer(self)
self.connect(self.oTimer, qt.SIGNAL('timeout()'), self.fOnTimer)
self.oTimer.start(100)
def closeEvent(self, e):
oApp.quit()
def fOnTimer(self):
self.c +=1
self.label.setText('%d' % self.c)
if self.c == 50:
qt.QMessageBox.critical(self, 'caption', 'lockup...')
oApp = qt.QApplication(sys.argv)
oMainWindow = TMainWindow(None, 'Main Window')
oMainWindow.show()
oApp.exec_loop()
I narrowed it down to a few lines of code (attached, I'm using PyQt but I'm sure this will be the same for the C++ interface).
Basically I pop up a simple dialog in a timer event. If the application is just sitting there everything is fine and the dialog pops up and the user can acknowledge it just fine. However, if the user holds down the mouse button on the application caption (starting of a drag operation) while the timer expires and the dialog pops up the entire application is frozen. Not only the application but all applications on the desktop are frozen. It seems like the mouse is captured and not released properly. I can close the dialog by pushing the ESC button. This will also allow to interact with all other applications.
I'm using Windows XP, Qt 3.3.1. I tested with Qt 2.3.0 and this does not occur, mostly due to the fact that the timer stops while dragging the window and therefore the dialog never pops up while the mouse is held down on the application.
Any solutions would be highly appreciated.
Thanks,
Tommy
import sys
import qt
class TMainWindow(qt.QMainWindow):
def __init__(self, *args):
qt.QMainWindow.__init__(self, *args)
self.label = qt.QLabel(self)
self.c=0
self.oTimer = qt.QTimer(self)
self.connect(self.oTimer, qt.SIGNAL('timeout()'), self.fOnTimer)
self.oTimer.start(100)
def closeEvent(self, e):
oApp.quit()
def fOnTimer(self):
self.c +=1
self.label.setText('%d' % self.c)
if self.c == 50:
qt.QMessageBox.critical(self, 'caption', 'lockup...')
oApp = qt.QApplication(sys.argv)
oMainWindow = TMainWindow(None, 'Main Window')
oMainWindow.show()
oApp.exec_loop()