[Qt-interest] boost::signals2 with Q_SLOTS - QPixmap not safe outside GUI thread?
Ed Sutton
edsutton at gmail.com
Wed Sep 23 20:19:03 CEST 2009
I understand the concept of single-threaded GUI and realize this
message is bad.
Here is what I am doing:
1 - My worker thread lib implements a boost::signal2.
2 - In my QT GUI project I have CONFIG += no_keywords and I replaced
the related keywords with the equivalent Q_ macros.
2 - My QMainWindow slot connects to the signal and receives the data
as demonstrated when I output the data to cout.
3 - Attempts to update statusBar()->showMessage() result in:
"QPixmap: It is not safe to use pixmaps outside the GUI thread"
How can I properly connect my worker thread using boost::signals2 to
the QT GUI thread?
Thanks in advance for any tips or direction,
-Ed
// Binding the worker thread signal to the MainWindow GUI handler
m_pMyWorkerThreadLib->connectOnDeviceParameterChanged(boost::bind(&MainWindow::onDeviceParameterChangedHandler,
this, _1));
class MainWindow : public QMainWindow
{
public Q_SLOTS:
// The GUI slot signalled from the worker
void onDeviceParameterChangedHandler( Device* pDevice)
{
// Beware: QPixmap: It is not safe to use pixmaps outside the GUI thread
statusBar()->showMessage(tr("onDeviceParameterChangedHandler"));
}
}
More information about the Qt-interest-old
mailing list