[Qt-interest] boost::signals2 with Q_SLOTS - QPixmap not safe outside GUI thread?

Andreas Pakulat apaku at gmx.de
Wed Sep 23 21:04:18 CEST 2009


On 23.09.09 13:19:03, Ed Sutton wrote:
> 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?

You can't. What you should do is create a Qt signal and a Qt slot and emit
the signal from onDeviceParameterChangedHandler. Then use Qt's connect()
function to connect the new Qt-signal with the new Qt-slot and supply
Qt::QueuedConnection as fith parameter. Now you can do the statusbar change
from within the new qtslot. Another way would be a custom Qt Event that you
post from onDeviceParameterChangedHandler and receive in
QMainWindow::event.

Andreas

-- 
Avoid gunfire in the bathroom tonight.



More information about the Qt-interest-old mailing list