Results 1 to 6 of 6

Thread: close application window

  1. #1
    Join Date
    Sep 2010
    Posts
    22
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default close application window

    Qt Code:
    1. myproject::myproject(QWidget *parent, Qt::WFlags flags): QMainWindow(parent, flags)
    2. {
    3. ui.setupUi(this);
    4. start();
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 


    how can i close widget window from the method??

    Qt Code:
    1. void myproject::start()
    2.  
    3. {
    4.  
    5. ui.centralwidget.close()
    6. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by seltra; 7th October 2010 at 19:19.

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: close widget window

    Hi,
    what exactly you would to do?
    You cannot close a widget contained by other widget. you can hide it

  3. The following user says thank you to mcosta for this useful post:

    seltra (7th October 2010)

  4. #3
    Join Date
    Sep 2010
    Posts
    22
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: close widget window

    Quote Originally Posted by mcosta View Post
    Hi,
    what exactly you would to do?
    You cannot close a widget contained by other widget. you can hide it
    I print on screen "Press Q to quit program"
    with keypressevent i check whether user presses Q_Key.

    Qt Code:
    1. void myproject::keyPressEvent ( QKeyEvent * event )
    2. {
    3. if(event->key() == Qt::Key_Q)
    4. {
    5. ui->close();
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 

  5. #4
    Join Date
    Sep 2010
    Posts
    22
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: close widget window

    i said false.
    i'm trying to quit application, not the widget.

    this code doesn't work..

    Qt Code:
    1. void myproject::keyPressEvent ( QKeyEvent * event )
    2. {
    3. if(event->key() == Qt::Key_Q)
    4. {
    5. app.quit();
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 

  6. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: close widget window


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

    seltra (8th October 2010)

  8. #6
    Join Date
    Sep 2010
    Posts
    22
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: close widget window

    Quote Originally Posted by Lykurg View Post
    thank you lykurg.
    Qt Code:
    1. qApp->quit();
    To copy to clipboard, switch view to plain text mode 
    solved my problem.

Similar Threads

  1. Replies: 9
    Last Post: 16th May 2010, 16:21
  2. Replies: 1
    Last Post: 19th April 2010, 07:19
  3. Replies: 4
    Last Post: 3rd October 2009, 08:19
  4. close window signal
    By jano_alex_es in forum Newbie
    Replies: 5
    Last Post: 22nd May 2009, 10:10
  5. How to close parent window from child window?
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 14th October 2008, 11:40

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.