[Interest] Unnecessary repaints.

william.crocker at analog.com william.crocker at analog.com
Thu Dec 17 22:24:51 CET 2015


On 12/17/2015 02:40 PM, william.crocker at analog.com wrote:
> On 12/17/2015 01:53 PM, Jason H wrote:
>>>
>>> If I call:
>>>
>>> QWidget::update() and
>>> QWidget::updateGeometry()
>>>
>>> Can I assume the layout request would be processed first and
>>> then any repaints would take place.
>>>
>>> In general can I assume that all layout requests would be serviced
>>> upon return to the event loop before any repaints.
>>
>> A troll might know otherwise, but that is the model I use when I do QWidget
>> subclasses (I've done several), and it's always worked like that for me. It'd
>> be a waste to to anything otherwise because you're doing a potentially
>> expansive paint operation on junk geometry.
>
> My understanding exactly.
>
> At one point I call QWidget::upateGeometry().
> A stack trace shows the call as part of a mouseReleaseEvent and so
> it appears to be made before returning to the event loop.
>
> Yet, the result is a delivery of a layout request event **after the paint**.
>
> If I comment it out, all is well.
>
> Do we agree that that does not make sense
> and I must be doing something wrong.
>

Well, the code deep inside of QWifget::updateGeometry boils down to this.
My call results in the postEvent. I assume that would be serviced
upon return to the event loop, and before the subsequent paint.

              if (parent->d_func()->layout)
                  parent->d_func()->layout->invalidate();
              else if (parent->isVisible())
                  QApplication::postEvent(parent, new 
QEvent(QEvent::LayoutRequest));

Or does that have nothing to do with QLayout and the QEvent::LayoutRequest
is sent after the paint. I am catching that in my widget event handler and
updating my widget geometry and calling update(). Is that where the second,
unexpected repaint is coming from.

Bill

>> The only thing I can think of is if someone calls their own (or a child
> widget's) repaint method directly, which I read somewhere is a no-no.(For
> obvious reasons).
>
> I do not do that.
>
>>
>>
>>
>>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>



More information about the Interest mailing list