Results 1 to 2 of 2

Thread: How to close a Dialog from another class?

  1. #1
    Join Date
    Sep 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to close a Dialog from another class?

    Hello all,

    I've created a function in my mainwindow class which opens a dialog.

    Qt Code:
    1. Dialog.exec();
    To copy to clipboard, switch view to plain text mode 

    After this a dialog opens up with 4 push buttons. I want everyone of these push buttons to set a string then close the dialog. I was able to set the string but have no clue how to close the dialog from the dialog class. Any ideas?
    I've seen some other threads mention signals and slots, but I still have no idea how that would be implemented. I would think I would run into the same situation (How would the dialog class know the signal was activated?).

    Thanks in advance for your help.


    Added after 10 minutes:


    Nevermind, I've figured it out. But if anyone else has this issue here is what I did:

    Qt Code:
    1. void Dialog::on_btn_clicked()
    2. {
    3. setString = "test";
    4. QDialog::close();
    5. }
    To copy to clipboard, switch view to plain text mode 

    I'm assuming the QDialog::close() command closes the current dialog (at least that is what it did for me).
    Last edited by TCaruso33; 17th September 2012 at 20:11.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to close a Dialog from another class?

    Call close(), reject() or accept().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 1
    Last Post: 20th January 2012, 04:39
  2. Replies: 4
    Last Post: 23rd August 2011, 21:53
  3. Replies: 2
    Last Post: 6th May 2011, 08:02
  4. How do i close a buttonless dialog.
    By geekshlby in forum Newbie
    Replies: 12
    Last Post: 12th January 2010, 08:26
  5. Close Dialog in showEvent
    By pospiech in forum Qt Programming
    Replies: 3
    Last Post: 11th April 2008, 15:32

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.