Results 1 to 4 of 4

Thread: update() propagation

  1. #1
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default update() propagation

    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

    Qt Code:
    1. QWidget (here update())
    2. |
    3. |
    To copy to clipboard, switch view to plain text mode 

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

    Not working
    Qt Code:
    1. QWidget (here update())
    2. |
    3. |
    4. |
    5. |
    To copy to clipboard, switch view to plain text mode 

    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.
    Last edited by Talei; 11th September 2012 at 03:18.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: update() propagation

    Do this way

    Qt Code:
    1. QWidget (here update())
    2. |
    3. |
    4. |
    5. - QWidget // <<<<<<<<<<<<<<<<<<<<<<<<<
    6. |
    7. |
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    Talei (11th September 2012)

  4. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: update() propagation

    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.

  5. The following user says thank you to ChrisW67 for this useful post:

    Talei (11th September 2012)

  6. #4
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: update() propagation

    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).
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

Similar Threads

  1. Transparency propagation question
    By gianpatt in forum Qt Programming
    Replies: 1
    Last Post: 30th September 2009, 16:54
  2. Event propagation direction
    By spraff in forum Qt Programming
    Replies: 0
    Last Post: 6th December 2008, 21:03
  3. Graphics View Event Propagation
    By pherthyl in forum Qt Programming
    Replies: 10
    Last Post: 3rd July 2008, 10:39
  4. KeyEvent propagation to Desktop
    By ^NyAw^ in forum Qt Programming
    Replies: 3
    Last Post: 27th November 2007, 12:38
  5. how to stop signals propagation further
    By babu198649 in forum Qt Programming
    Replies: 13
    Last Post: 27th November 2007, 10:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.