Results 1 to 5 of 5

Thread: Is there an event or signal after the UI has been set

  1. #1
    Join Date
    Nov 2014
    Posts
    35
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Is there an event or signal after the UI has been set

    Hello,

    I have QMainWindow with a QSplitter as the central widget, and the splitter has two QWidgets: top_widget and bottom_widget. I'd like to set the default size of bottom_widget to 100 on new, and allow this size to be saved and loaded. On Load I want to restore this value.

    My question is: Where is the best place to set this default size to 100? Is there an event or signal the the QMainWindow receives after all children widgets have been positioned and resized?

    Thank you!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Is there an event or signal after the UI has been set

    There are many possibilities, e.g. using invokeMethod() with Qt::QueuedConnection. Or you can do that the first time the widget is shown (using showEvent()). Or possibly using other means.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,321
    Thanks
    316
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Is there an event or signal after the UI has been set

    In my apps I find it easiest to restore the window state in the showEvent() and to save it in the closeEvent(). You can also restore the state in the constructor if you wish, and it will be applied when the window is shown.

  4. #4
    Join Date
    Nov 2014
    Posts
    35
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is there an event or signal after the UI has been set

    Thank you! I'll try your suggestions. For the moment I am doing my stuff in the resize event only when the top and bottom widgets have size, and only once...

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,321
    Thanks
    316
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Is there an event or signal after the UI has been set

    I am doing my stuff in the resize event
    Better to do it in the show event. When this occurs, the widget (and its children) have been properly sized and positioned (by layouts), so you can safely examine their sizes and positions and resize or move them as you wish.

    As you have probably seen, the resize event can be called multiple times, including when widgets have no sizes.

Similar Threads

  1. ACE Thread and QT signal or event
    By opengllove in forum Newbie
    Replies: 1
    Last Post: 27th December 2013, 13:07
  2. disabling the signal event
    By aj2903 in forum Qt Programming
    Replies: 6
    Last Post: 13th July 2012, 11:26
  3. signal/slot or subclassed event?
    By liqxpil in forum Qt Programming
    Replies: 3
    Last Post: 4th November 2010, 11:15
  4. event loop isStarted() signal?
    By Xerion in forum Qt Programming
    Replies: 1
    Last Post: 18th February 2008, 21:45
  5. QTreeWidgetItem signal or event
    By db in forum Newbie
    Replies: 1
    Last Post: 20th October 2007, 14:18

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.