QObject::startTimer error message when quitting a PyQt app
-
I'm not sure if this is the right place to post this, but I'd be grateful if anyone could steer me in the right direction, because I'm pretty well stumped. When I quit my application, I get this error message in the debug I/O console, repeated many times:
QObject::startTimer: QTimer can only be used with threads started with QThreadI've googled this and everybody else who has this trouble has a few straightforward causes that I think I've ruled out, such as:
-- Starting a timer with no event loop running
-- Starting/stopping a timer from a thread other than the one that created the timer
-- Failing to set the parent property of a widget, leading to problems with the order of destructionBelow I have a minimal code sample that demonstrates the problem. Notice that I've started no threads or timers. I also have set the parent of every widget. If I remove the graph widgets, the problem goes away, so one is tempted to blame pyQtGraph, however, if I include the plot widgets but exclude all the blank tabs (i.e. every tab except tabCatchaTiger), the problem also goes away, and that seems to vindicate pyQtGraph.
Versions:
Windows 7
Python 2.7.8
Wing IDE 5.0.9-1
PyQt 4.11.1
PyQwt 5.2.1
PyQtGraph 0.9.8Test case:
@
from PyQt4 import Qt, QtGui, QtCore
import PyQt4.Qwt5 as Qwt
import pyqtgraph as pgpg.functions.USE_WEAVE = False # Lets pyqtgraph plot without gcc
pg.setConfigOption('background', 'w')
pg.setConfigOption('foreground', 'k')GUI for visualizing data from database
class crashyGUI(QtGui.QWidget) :
def __init__(self) : # Make the window QtGui.QWidget.__init__(self) self.resize(700, QtGui.QDesktopWidget().screenGeometry(self).height()*.85) self.setWindowTitle('Data Visualization') # Create tab interface tabWidget = QtGui.QTabWidget(self) # define the tab objects self.tabEeny = QtGui.QWidget(tabWidget) self.tabMeeny = QtGui.QWidget(tabWidget) self.tabMiney = QtGui.QWidget(tabWidget) self.tabMoe = QtGui.QWidget(tabWidget) self.tabCatchaTiger = QtGui.QWidget(tabWidget) self.tabByThe = QtGui.QWidget(tabWidget) self.tabToe = QtGui.QWidget(tabWidget) # Initialize the tab objects self.initTabCatchaTiger() ########################################### ############### Main Layout ############### ########################################### tabWidget.addTab(self.tabEeny, 'Eeny') tabWidget.addTab(self.tabMeeny, 'Meeny') tabWidget.addTab(self.tabMiney, 'Miney') tabWidget.addTab(self.tabMoe, 'Moe') tabWidget.addTab(self.tabCatchaTiger, 'Catch a Tiger') tabWidget.addTab(self.tabByThe, 'By The') tabWidget.addTab(self.tabToe, 'Toe') self.mainLayout = QtGui.QVBoxLayout(self) self.mainLayout.addWidget(tabWidget) self.setLayout(self.mainLayout) def initTabCatchaTiger(self): ########################################### ############# ADC Capture Tab ############# ########################################### # define tab layout grid = QtGui.QGridLayout(self.tabCatchaTiger) # create copy of adc plot and add to row 3 of the grid self.catchaTigerPlot1 = pg.PlotWidget(name = 'Catch a Tiger 1', parent = self.tabCatchaTiger) self.catchaTigerPlot1.setTitle('Catch a Tiger 1') grid.addWidget(self.catchaTigerPlot1, 2, 0, 1, 8) self.catchaTigerPlot2 = pg.PlotWidget(name = 'Catch a Tiger 2', parent = self.tabCatchaTiger) self.catchaTigerPlot2.setTitle('Catch a Tiger 2') grid.addWidget(self.catchaTigerPlot2, 3, 0, 1, 8) # set layout for tab self.tabCatchaTiger.setLayout(grid) def closeEvent(self, event) : pass
def main() :
# open a QApplication and dialog() GUI
app = QtGui.QApplication([])windowCrashy = crashyGUI() windowCrashy.show() app.exec_()
main()
@ -
I had the same "error message" in my quite different setup. Following a hint in a different thread (maybe in a different forum, can't remember), setting main widget's window_attribute to Qt.WA_DeleteOnClose in [doubleunderscore]init[doubleunderscore], like so:
@self.setAttribute(55)@
solves the problem. It seems to be an item with pyqt's garbage collection.
Brgds, a.
PS Don't know who classified me as Lab Rat, must be some kinda default
PPS What crap of forum is this, where I can't use underscores in a code section?
-
Hi and welcome to devnet,
@
def closeEvent(self, event) :
pass
@is wrong
You should either remove that function or call accept on event in order to properly close the window
At alchwarismi
For code related writing, you should rely on the coding tags like you already did.
e.g.@.init()@
The underscores are used to put text in italic.
As for the LabRat, it's an indication to let other user know your involvement on the site.