Results 1 to 4 of 4

Thread: close window when click on a label

  1. #1
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default close window when click on a label

    hi,
    I have a label in my form and it has an event clicked, ( which one i emit click() from mousePressEvent ). I need to close this window when i clicked on this label. When we click on this label, we can call a function. From that function, how can i close the window. Please help me

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: close window when click on a label

    See QCoreApplication::quit() and QWidget::close. You can connect to one of these slots, but if you want the application to exit you should use the first signal(via the qApp pointer)

  3. #3
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: close window when click on a label

    Hi,
    I try this, but my probs is that, from my mainwindow i create an another window and in that child window I have a label and in the click event of that label, I want to close the child window. when i try this,

    connect(LblVStop, SIGNAL(clicked()), this, SLOT(quit()));
    it hide that label only, not window. I need to close that window
    Please help me....

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: close window when click on a label

    Use:
    Qt Code:
    1. connect(LblVStop, SIGNAL(clicked()), this, SLOT(close()));
    To copy to clipboard, switch view to plain text mode 
    This works if "this" is the window you want to close.
    BTW, there's no slot called quit() in a QWidget or a QMainWindow.

  5. The following user says thank you to marcel for this useful post:

    sabeesh (29th October 2007)

Similar Threads

  1. QTextBrowser - click on link - closes window
    By bruccutler in forum Newbie
    Replies: 2
    Last Post: 19th June 2007, 21:39
  2. Replies: 1
    Last Post: 9th February 2007, 10:41
  3. How to "hide window when close button pressed"
    By iGoo in forum Qt Programming
    Replies: 4
    Last Post: 26th July 2006, 10:53
  4. Replies: 3
    Last Post: 23rd July 2006, 19:02

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.