PDA

View Full Version : How to hide mainwindow at program start up



palmer
13th September 2008, 05:33
I want my program run without displaying GUI or Console, i tried like this:
In the constructor of MainWindow( inherited from QMainWindow), call the member function setVisible(false) or hide(), but that did not work.
how to hide mainwindow at program start up?
thks!

santhoshv84
13th September 2008, 05:54
Hi,

Use the main() function like this..


int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Test w;
w.show();
w.hide();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}

Thanks and regards,
Santhosh

jpn
13th September 2008, 13:54
What's the point of calling show() and hide() in a row? Just don't call show() in the first place.

palmer
13th September 2008, 15:33
thanks for all of you.
What i want to do is that: In an application, i use QProcess to start the program and send messages to it using WIN32 API SendMessage, and this API function needs Windows handle as parameter, So the program must has 'window'.
I will try the solutions you provided.
thank you and best regard!

jpn
13th September 2008, 15:35
So create a QWidget and use winId() to get the handle. QWidget is not visible by default. If you don't want to show it, don't call show().