[Qt-interest] QProgresBar + QThread = It is not safe to use pixmaps outside the GUI thread

Miguel Cardenas mfcardenas at gmail.com
Fri Aug 14 19:40:57 CEST 2009


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/a2bf4be5/attachment.html 


More information about the Qt-interest-old mailing list