Results 1 to 9 of 9

Thread: accessing my main application window widget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: accessing my main application window widget

    Well... basicly you can call parent() as long as it returns something other than null. The last non-null result returned will be the main window.

    Alternatively you can just call qApp->mainWidget() (just remember to #include <qapplication.h> and to set the main widget in main() ).

  2. #2
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: accessing my main application window widget

    Quote Originally Posted by wysota View Post
    Well... basicly you can call parent() as long as it returns something other than null. The last non-null result returned will be the main window.

    Alternatively you can just call qApp->mainWidget() (just remember to #include <qapplication.h> and to set the main widget in main() ).
    I tried setting the main widget in main() like so:

    Qt Code:
    1. #include <QApplication>
    2. #include "mymainwidg.h"
    3. int main(int argc, char** argv)
    4. {
    5. QApplication app(argc, argv);
    6. MyMainWidg widg;
    7. app.setMainWidget(&widg);
    8. widg.show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    My compiler whines that setMainWidget is undeclared. What have i missed? Was setMainWidget perhaps not available in version 4.2.2?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: accessing my main application window widget

    Quote Originally Posted by TheRonin View Post
    My compiler whines that setMainWidget is undeclared. What have i missed? Was setMainWidget perhaps not available in version 4.2.2?
    It's available only as a part of Qt3 Support module.

  4. The following user says thank you to jacek for this useful post:

    TheRonin (1st November 2007)

Similar Threads

  1. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 08:41
  2. closing dialog in hidden main Widget
    By Lele in forum Qt Programming
    Replies: 3
    Last Post: 6th December 2006, 10:35
  3. Replies: 5
    Last Post: 4th August 2006, 23:44
  4. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 10:21
  5. Main window
    By Michiel in forum Qt Tools
    Replies: 1
    Last Post: 20th March 2006, 23:54

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.