PDA

View Full Version : update() propagation



Talei
11th September 2012, 04:10
Hello,
I have problem with the update() propagation to the child widgets and I don't know why update is not propagated further to the children.

What works:

Main QWidget with the QGridLayout


QWidget (here update())
|
- QGridLayout
|
- QWidget
- QWidget

In that case update is propagated to the QWidgets in the layout.

Not working

QWidget (here update())
|
- QVBoxLayout
|
- QScrollArea
|
- QGridLayout
|
- QWidget
- QWidget

In that setup update(), on the main widget, is not propagated further down.

QWidget's in the QGridLayout contains QImage that is painted on the update() (in paintEvent());
Calling update() for each widget in the qgridlayout works ok.
Calling update for any parent layout or widget don't update further down.

Any help is more then welcome.

PS.
Using update from the main QWidget on the
QWidget ->update();
QVBoxLayout->update();
QScrollArea->update();
QGridLayout->update();

don't trigger update in QWidget in the QGridLayout().

On the resizeEvent() / resize widget everything works fine.

Santosh Reddy
11th September 2012, 05:25
Do this way


QWidget (here update())
|
- QVBoxLayout
|
- QScrollArea
|
- QWidget // <<<<<<<<<<<<<<<<<<<<<<<<<
|
- QGridLayout
|
- QWidget
- QWidget

ChrisW67
11th September 2012, 05:41
Widgets are painted when required. QLayout::update() has no effect on painting unless the layout has to actually change the location or size of widgets. The content of a QScrollArea exists in a virtual space (the viewport) and only the visible portion is involved in painting on the screen. Unless you change the QScrollArea size, scroll bar positions, visibility, or content size then the area content does not need to be repainted.

You can call the scroll area's viewport()->update() if you really must. However, if the images in the lower level widgets are changing then they should be ensuring they update themselves. This should not require external triggering.

Talei
11th September 2012, 06:30
Thanks ChrisW67
It's exactly how You explained, using QScrollArea()->update(); didn't triggered update but using QScrollArea()->viewport()->update(); did the trick.

I currently have "self updating" mechanism on the QWidget with the images but I just was curious what force that behaviour (it was in my previous code iteration).