Results 1 to 5 of 5

Thread: How to hide mainwindow at program start up

  1. #1
    Join Date
    Sep 2007
    Posts
    2
    Thanks
    2

    Default How to hide mainwindow at program start up

    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!

  2. #2
    Join Date
    May 2008
    Posts
    42
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4

    Default Re: How to hide mainwindow at program start up

    Hi,

    Use the main() function like this..

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication a(argc, argv);
    4. Test w;
    5. w.show();
    6. w.hide();
    7. a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
    8. return a.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 

    Thanks and regards,
    Santhosh
    Last edited by jpn; 13th September 2008 at 13:53. Reason: missing [code] tags

  3. #3
    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 hide mainwindow at program start up

    What's the point of calling show() and hide() in a row? Just don't call show() in the first place.
    J-P Nurmi

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

    palmer (13th September 2008)

  5. #4
    Join Date
    Sep 2007
    Posts
    2
    Thanks
    2

    Default Re: How to hide mainwindow at program start up

    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!

  6. #5
    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 hide mainwindow at program start up

    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().
    J-P Nurmi

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

    palmer (13th September 2008)

Similar Threads

  1. QProcess start a console program
    By Shawn in forum Qt Programming
    Replies: 2
    Last Post: 9th November 2007, 13:38
  2. I start a external fortram program, how to terminate?
    By dolphins in forum Qt Programming
    Replies: 3
    Last Post: 28th October 2007, 14:07
  3. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 05:19

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.