PDA

View Full Version : show/hide QMainWindow from another QMainWindow



PauloF91
14th June 2013, 00:43
Hello.

In my program I got 2 QMainWindows. How can I show/hide my second Window from the first?
In the constructor of the second Window I got "this->show();" and it does show without a problem.
But when I create a slot in the first Window to run this as well ( this->show(); ) in another function in my second Window class it says: 'this' is unavailable for static member functions.
(so, in a slot of my first window class I try to access a static function in my second Window class)
I hope I made myself clear. This function I'm trying to access is static, but I dont think I should keep it that way.

I can type my code if its easier for you.

For the record, this second window is basically a widget, a label. I just want it aside from my (true) main window.

Thanks in advance.

Santosh Reddy
14th June 2013, 04:53
If you want two windows in your application, then first you will need to create two instance (objects) of windows (widgets), only then you can show them. Using static functions to show is ok as long as you create the object of the second widget.

PauloF91
14th June 2013, 10:18
I do create it, but i still haven't figured out a way to do it. I'll keep digging.

No matter how I try it, there's always a conflict between static or non static members.
In My main() I instanciate both mainWindows. All I want is to be able to show/hide one from the other.

anda_skoa
14th June 2013, 11:22
Forget about static members when you are dealing with two instances.

You either pass a pointer of one window to the other and then call methods on it, or you have one window emit signals and connect that to the other window's slots.

Cheers,
_