Results 1 to 4 of 4

Thread: How can i check if QMainWindow is fully loaded ?

  1. #1
    Join Date
    May 2009
    Posts
    83

    Default How can i check if QMainWindow is fully loaded ?

    Hi
    in my application i like to invoke method only after the window on the QMainWindow is fully loaded ,
    how can i check this ? is there any onLoad callback/signal ? ( i checked and didn't found any thing )
    Thanks

  2. #2
    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: How can i check if QMainWindow is fully loaded ?

    What do you mean by "fully loaded"?

    You can trigger some activity when the program returns to the Qt event loop with a single-shot timer at the end of the constructor:
    Qt Code:
    1. #include <QtGui>
    2. #include <QDebug>
    3.  
    4. class MainWindow: public QMainWindow {
    5. Q_OBJECT
    6. QLabel *label1;
    7. QLabel *label2;
    8. public:
    9. MainWindow(QWidget *p = 0): QMainWindow(p) {
    10. QWidget *central = new QWidget(this);
    11. label1 = new QLabel("Label 1", this);
    12. label2 = new QLabel("Label 2", this);
    13.  
    14. QVBoxLayout *layout = new QVBoxLayout(central);
    15. layout->addWidget(label1);
    16. layout->addWidget(label2);
    17.  
    18. central->setLayout(layout);
    19. setCentralWidget(central);
    20.  
    21. QTimer::singleShot(0, this, SLOT(doLater()));
    22. }
    23. public slots:
    24. void doLater() {
    25. // Executes when event loop reached (after show in this case)
    26. label2->setText("I've been changed");
    27. }
    28.  
    29. private:
    30. };
    31.  
    32. int main(int argc, char *argv[])
    33. {
    34. QApplication app(argc, argv);
    35.  
    36. MainWindow m;
    37. m.show();
    38. return app.exec();
    39. }
    40. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can i check if QMainWindow is fully loaded ?

    also try showEvent()

  4. #4
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can i check if QMainWindow is fully loaded ?

    umen do you mean Form.OnLoad method ala .NET environment? No I think things run differently here. But if you want it that way you can definitely use signals and slots to come up with something similar in no time..

Similar Threads

  1. QGraphicsView scrollbar not fully visible
    By jazuju in forum Newbie
    Replies: 2
    Last Post: 25th May 2011, 10:38
  2. QWidget setMask fully transparent.
    By bunjee in forum Qt Programming
    Replies: 5
    Last Post: 6th August 2009, 13:30
  3. Fully qualified X font name
    By piotrek in forum Qt Programming
    Replies: 0
    Last Post: 26th March 2009, 15:16
  4. Qt4 is not fully honoring palette configuration
    By hagabaka in forum Installation and Deployment
    Replies: 1
    Last Post: 1st August 2008, 00:38
  5. Replies: 1
    Last Post: 23rd April 2007, 17:48

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.