[Qt-interest] Widget does not update content after some time

Damien R damien.rg+news at gmail.com
Thu Oct 22 11:00:14 CEST 2009


> Although update() may not cause an immediate paint, it is not
> documented to be thread-safe, which means that it is probably only
> reentrant. Since the "Thread Support in Qt" page states "Classes in
> the documentation will be documented as thread-safe only if they are
> intended to be used by multiple threads."

I agree with you, I misinterpreted the documentation of update.

> Thread-safe communication can be accomplished by using queued signals.
> For example,
>
> // Define a signal and slot
>     Q_OBJECT
>
>     signals:
>         void signalUpdate();
>
>     public slots:
>         void updateSlot() {
>             update();
>         }
>
> // Connect the signal and slot as a queued connection
>     connect(this, SIGNAL(signalUpdate()), this, SLOT(updateSlot()),
> Qt::QueuedConnection);
>
> // Send signal rather than call update() in setImage()
>     //update();
>     signalUpdate();
Yes, and it is not necessary to create an updateSlot because update is
already a slot. connect should use Qt::QueuedConnection automatically
but I set it to Qt::QueuedConnection.

I need to do more test to be sure it's works.
-- 

Damien R.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091022/44635f31/attachment.html 


More information about the Qt-interest-old mailing list