Results 1 to 7 of 7

Thread: Parent Child for window

  1. #1
    Join Date
    Feb 2009
    Posts
    29
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Parent Child for window

    Hi all,
    I have a doubt.
    I have 2 QMainWindow. Can i make a one QMainWindow as the child of another QMainWindow???

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Parent Child for window

    yes, you can.
    Qt Code:
    1. Test::Test(QWidget *parent)
    2. : QMainWindow(parent)
    3. {
    4. QTabWidget *tabWidget = new QTabWidget();
    5.  
    6. QWidget *page = new QWidget();
    7. QHBoxLayout *layout = new QHBoxLayout(page);
    8.  
    9. m_pbNewWindow = new QPushButton(tr("New window"));
    10. layout->addWidget(m_pbNewWindow);
    11. tabWidget->addTab(page, tr("Test"));
    12.  
    13. connect(m_pbNewWindow, SIGNAL(clicked()), SLOT(newWindow()));
    14.  
    15. setCentralWidget(tabWidget);
    16. }
    17.  
    18. void Test::newWindow()
    19. {
    20. Test *test = new Test(this);
    21. test->setAttribute(Qt::WA_DeleteOnClose);
    22. test->show();
    23. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Parent Child for window

    technically yes, but they wont come one inside another. plus what is your motivation for this atrocity

  4. #4
    Join Date
    Feb 2009
    Posts
    29
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Parent Child for window

    ok...can it be displayed as a pop-up window. i.e. if i click a button from the parent QMainWindow, can pop-up the 2nd QMainWindow??

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Parent Child for window

    don't my example work?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. #6
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Parent Child for window

    Quote Originally Posted by febil View Post
    ok...can it be displayed as a pop-up window. i.e. if i click a button from the parent QMainWindow, can pop-up the 2nd QMainWindow??
    yes that can happen of course but why a window..why not a widget? would you like to explain why u need such a behaviour. Possibly there might be more efficient ways of attaining your goals

  7. #7
    Join Date
    Feb 2009
    Posts
    29
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Parent Child for window

    Dear Spirit, i will try based on ur example.

    Dear talk2amulya, i have a mainwindow and when i clicked a button from the main window, i need to display another window. This window contains menu, toolbar, tool buttons etc... so i think i need to use QMainWindow.

Similar Threads

  1. let parent widget grow with child widget?
    By BeS in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2009, 11:17
  2. connecting child to parent window...
    By sumit in forum Qt Programming
    Replies: 1
    Last Post: 19th October 2008, 21:28
  3. How to close parent window from child window?
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 14th October 2008, 11:40
  4. Move child widget along with the parent widget
    By sreedhar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2006, 12:00
  5. Referencing Parent Widget from Child
    By taylor34 in forum Qt Programming
    Replies: 8
    Last Post: 11th April 2006, 15:13

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.