Results 1 to 5 of 5

Thread: How to show two main windows?

  1. #1
    Join Date
    Oct 2008
    Posts
    29
    Qt products
    Qt4
    Platforms
    Windows

    Default How to show two main windows?

    Hi, I´m new here.

    I´m developing a qt application and I have a main window as application's user interface. I have several dialogs too.

    My problem is I have to develop a new module for the app and it must have a toolbar, stastusbar, etc. As I can´t develop this elements with a QDialog I need a QMainWindow, but when I call show() from the principal window to show the new window it is shown and closed.

    How can I show a main window from another main window?

    Thanks in advance.
    Regards.

  2. #2
    Join Date
    Jul 2006
    Location
    Atlanta, GA
    Posts
    86
    Thanks
    26
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to show two main windows?

    Couldn't you just use an mdi area and change the toolbar when the other "main window" is opened?
    fnmblot
    --------------------------------------
    Gee Ricky, I'm sorry your mom blew up.

  3. #3
    Join Date
    Oct 2008
    Posts
    29
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to show two main windows?

    Hi fnmblot

    If I use a mdi area, I only can show a window at every moment, isn't?

    I need to show a main window from another but I don't want to hide or close it.

    Regards.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to show two main windows?

    Sounds like you allocate the window on the stack and therefore it goes out of scope according to normal C++ rules:
    Qt Code:
    1. {
    2. QMainWindow window;
    3. window.show();
    4. } // window goes out of scope
    To copy to clipboard, switch view to plain text mode 
    You should allocate the window on the heap with C++ operator new.
    J-P Nurmi

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

    td (23rd October 2008)

  6. #5
    Join Date
    Oct 2008
    Posts
    29
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to show two main windows?

    Hi jpn

    It´s true! The window goes out of the scope and disappears. I´ve designed it using singleton pattern and now it works fine.

    I didn´t think that the problem was that. I was thinking that a window didn´t show other window.

    Thanks a lot.

Similar Threads

  1. setting main application icon on windows
    By JeanC in forum Qt Programming
    Replies: 7
    Last Post: 12th June 2017, 05:35
  2. Replies: 11
    Last Post: 11th August 2008, 09:14
  3. show() in central main window
    By ufo-vl in forum Newbie
    Replies: 3
    Last Post: 28th July 2007, 02:33
  4. How to close all windows that were created in main()?
    By Mister_Crac in forum Qt Programming
    Replies: 6
    Last Post: 13th November 2006, 10:57
  5. Replies: 5
    Last Post: 4th August 2006, 23:44

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.