[Qt-interest] Slots in threads ?
Will Rutherdale (rutherw)
rutherw at cisco.com
Thu Aug 27 19:07:04 CEST 2009
The way I normally do it is to have a worker object (with class derived
from QObject) and call the object's moveToThread() to attach it to your
thread. You do not subclass QThread but use it directly, then call its
start(). This will run its event loop by default. You connect slots in
the worker object to the appropriate signals. Then when those signals
are emitted the object will do its work within the thread.
-Will
________________________________
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Patric
Sent: 27 August 2009 12:48
To: qt-interest at trolltech.com
Subject: [Qt-interest] Slots in threads ?
Hello,
I have a little gui program with one worker thread. I want to
stop and start the thread from the gui. So I put some slots inside the
thread. But now I'm getting some errors on compilation :
mainwindow.cpp: In constructor
`MainWindow::MainWindow(QWidget*)':
mainwindow.cpp:35: error: no matching function for call to
`MainWindow::connect(Board*&, const char*, Engine*, const char*)'
c:/Qt/2009.03/qt/include/QtCore/../../src/corelib/kernel/qobject.h:202:
note: candidates are: static bool QObject::connect(const QObject*, const
char*, const QObject*, const char*, Qt::ConnectionType)
c:/Qt/2009.03/qt/include/QtCore/../../src/corelib/kernel/qobject.h:308:
note: bool QObject::connect(const QObject*, const char*, const char*,
Qt::ConnectionType) const
Am I allowed to put slots in threads ?
Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090827/0215022f/attachment.html
More information about the Qt-interest-old
mailing list