PDA

View Full Version : Threads and QwtPainter::drawText



AwDogsgo2Heaven
14th July 2009, 22:53
Hello, I'm trying to run the 'drawCanvas' function in a seperate thread. However, QwtPainter::drawText has been a show stopper for me.

Q_ASSERT(qApp && qApp->thread() == QThread::currentThread());

I'm confronted with this debug error shower above. Which I'm assuming its complaining that the GUI thread is not calling this, but I don't understand why.

Going up the call stack eventually leads to this:

QNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform);

And going further up stops me at QwtPainter::drawText of course... specifically this one

void QwtPainter::drawText(QPainter *painter, int x, int y,
const QString &text)

my painter's device is a QImage.

If anyone has any ideas or solutions, I would be thankful!

AwDogsgo2Heaven
15th July 2009, 17:45
Sorry for double post, I couldn't find the edit button if there is one.

I believe this is a problem of using fonts/text outside of the main thread. I have read about using QPainterPaths as a work around but it would require alot of subclassing.
And even if you used QPainterPaths you must create them in the GUI which is also inconvient.

I'm hoping to find a more ideal solution if possible.