Results 1 to 13 of 13

Thread: How to close a QDialog??

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to close a QDialog??

    That's the Designer I meant
    Ok, here is what to do: open the form for editing, right click on your close button, left click on "Go to Slot..."
    This will create a slot for you in the .h and .cpp files and immediately show the .cpp slot code in your editor.
    Inside that slot function, put the code: close(); and any other code you need to execute before closing the dialog - your choice.
    Now your dialog is modal (by using the exec() to open it, so no other window is active until you close it, and clicking the 'close' button or whatever you called it, will close your dialog.
    This is the cheap and easy way of making your close or cancel button work.
    Does that do it?

  2. #2
    Join Date
    Aug 2010
    Posts
    107
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to close a QDialog??

    i know about the go slot and all that.. ok i added just close(); and the button doesn't do enything..

    Qt Code:
    1. void preferences::on_pushButton_3_clicked()
    2. {
    3. close();
    4. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to close a QDialog??

    Ok, try this then:

    <yourdialogname>::close();

  4. #4
    Join Date
    Aug 2010
    Posts
    107
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to close a QDialog??

    Qt Code:
    1. void preferences::on_pushButton_3_clicked()
    2. {
    3. <gamatos>::close();
    4. }
    To copy to clipboard, switch view to plain text mode 

    4 errors :P

    And if i do that

    Qt Code:
    1. void preferences::on_pushButton_3_clicked()
    2. {
    3. gamatos::close();
    4. }
    To copy to clipboard, switch view to plain text mode 

    It says gamatos was not declared on this scope...
    Attached Images Attached Images

  5. #5
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to close a QDialog??

    Bong, the <> is just notation to indicate this is where to insert your value.

    What is the name of your dialog class?

Similar Threads

  1. How to close a local QDialog?
    By MorrisLiang in forum Newbie
    Replies: 2
    Last Post: 23rd August 2010, 10:19
  2. Deleting QDialog object on close
    By ahmdsd_ostora in forum Qt Programming
    Replies: 2
    Last Post: 28th June 2010, 09:55
  3. How can I avoid a QDialog close?
    By ricardo in forum Qt Programming
    Replies: 7
    Last Post: 11th May 2009, 19:29
  4. QDialog not showing close button on Mac
    By manojmka in forum Qt Programming
    Replies: 2
    Last Post: 17th September 2008, 12:56
  5. Replies: 1
    Last Post: 7th July 2007, 09:03

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.