[Solved] How to hide and show a mainwindow?
So a dialog can be hide with hide(); and can been shown with show();
But what about if it is not a dialog but the mainwindow?
hide(); doesn’t hide my mainwindow….
My app pops app a dialog and from there you can take a screenshot. And it has the ability to hide the dialog and after the screenshot has been take show it again. But i also want to hide the mainwindow..
So at the mainwindow hide(); doesn’t hide the window.. What’s wrong?
Just a guess: maybe you are calling hide() method/function of the wrong object (ie: not for the main window) by accident? Check it! ;-)
As for an example… Putting hide(); at the constructor of the mainwindow.cpp won’t hide the window…
I suspected that’s what you were doing. I don’t think that should be expected to work. Although, the QMainWindow is constructed by then, i think you should try it after the construction of the MainWindow object is complete. Also, are you saying that the main window is shown without calling show()? Because you call hide() in the MainWindow constructor, where do you call show?
could you make an new widget based Qt project, choose a QMainwindow as class and use the following code in your main.
like this :
normally this should work unless you have other issues.
Ok so probably it was wrong to put hide(); at the constructor.. Putting it in a void function will work..
I made an example that hides both the dialog and the mainwindow :) (Link [dl.dropbox.com])