PDA

View Full Version : How to show two main windows?



Althor
9th October 2008, 23:06
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.

fnmblot
10th October 2008, 19:10
Couldn't you just use an mdi area and change the toolbar when the other "main window" is opened?

Althor
10th October 2008, 20:45
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.

jpn
12th October 2008, 10:15
Sounds like you allocate the window on the stack and therefore it goes out of scope according to normal C++ rules:


{
QMainWindow window;
window.show();
} // window goes out of scope

You should allocate the window on the heap with C++ operator new.

Althor
13th October 2008, 09:30
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.