[Qt-interest] QProgresBar + QThread = It is not safe to use pixmapsoutside the GUI thread
Scott Aron Bloom
Scott.Bloom at sabgroup.com
Fri Aug 14 20:00:54 CEST 2009
Communicate across the threads via a signal/slot interface...
Emit a signal "start", "progress", "finished" from the worker thread...
Have the GUI side that owns the progressbar, update the progressbar
based on the signal data
Scott
________________________________
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Miguel Cardenas
Sent: Friday, August 14, 2009 10:41 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] QProgresBar + QThread = It is not safe to use
pixmapsoutside the GUI thread
Hello
I'm developing a QMainWindow application, it launches a QThread (non
graphic, just internal tasks) to perform some operation in the
background to avoid blocking the user interface while it works...
In the QMainWindow object there is a QProgressBar to show the progress
of the process (in background), so I pass the progress bar pointer to
the QThread object before running, so it can show the progress, but it
appears not to work, I get these errors in console and no progress is
shown:
QPixmap: It is not safe to use pixmaps outside the GUI thread
.
. // about 50 of these
.
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPainter::begin: Cannot paint on a null pixmap
QPainter::setPen: Painter not active
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
Major opcode: 62 (X_CopyArea)
Resource id: 0x0
.
. // abouth 50 of these others
.
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
Major opcode: 62 (X_CopyArea)
Resource id: 0x0
My doubt is, how can I do to access the QMainWindow::QProgressBar from
the QThread? I was thinking of creating the bar inside the QThread, then
get the QProgressBar pointer from it and then insert it into the
QMainWindow layout... but it should be a mess...
Any idea of how can I solve the problem?
I am using Linux Slackware 12.1 with KDE
Thanks
--
Miguel Cardenas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090814/d5c14925/attachment.html
More information about the Qt-interest-old
mailing list