On Wed, Apr 3, 2013 at 3:44 AM, Sensei <[email protected]> wrote:

> Dear all,
>
> I am using multiple threads in my application, and now I am wondering if
> I am doing something bad.
>
> My application has a 'worker' thread that builds a tree with
> QTreeWidgetItems, setting QIcons for them.
>
> Reading around, I found contradictory information about QPixmap (a
> warning that triggered my question here) and non-GUI threads.
>
> Is this code safe to execute in a thread? The underlying graphic system
> *IS* initialized and running at the time the thread starts, this is
> something I can guarantee.
>
>
>   item = new QTreeWidgetItem(QStringList(params));
>   item->setIcon(0, QIcon(icons[i]));          // WARNING !!!
>   item->setData(1, 0, QVariant(file));
>   item->setData(2, 0, QVariant(idx));
>

no. You can't create widgets or QPixmap in other threads.


>
>
> The warning is "QPixmap: It is not safe to use pixmaps outside the GUI
> thread".
>

Correct.



>
> Also, besides QIcons, am I heading for disaster in creating widgets as I
> am doing in a separate threads?
>

Yes.
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to