[Qt-interest] Few questions about drawing text

Bo Thorsen bo at fioniasoftware.dk
Mon Sep 6 08:41:15 CEST 2010


Den 05-09-2010 17:08, Cyril C skrev:
>   Hi all, I've got simple questions related to text drawing in Qt, for
> which I can't figure out a proper answer.
>
> 1a. Is it legal and portable to draw text in a non-GUI thread onto a
> QImage using QPainter::drawText? From this nice article by Gunnar (
> http://labs.trolltech.com/blogs/category/painting ) it seems so, but I
> am still sceptical..

That should work. QImage is one of the few "gui" classes you can use in 
other threads, since it's just an internal blob of memory. Be careful 
when passing it to other threads though.

> 1b. Of course I would prefer drawing to a GLTexture (and not only text)
> but my understanding is that even in 4.7, drawing to a QGLContexts in
> separate threads won't be supported, is that right?

That certainly won't work. GL stuff is a hardware thing, not implemented 
in memory like QImage. AFAIK, you can't even protect all GL access with 
mutexes (which would anyway completely ruin the idea of threads).

Bo Thorsen,
Fionia Software.

-- 

Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk



More information about the Qt-interest-old mailing list