Results 1 to 8 of 8

Thread: QDialog ?

  1. #1
    Join Date
    May 2006
    Posts
    33
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default QDialog ?

    I've got a simple app (no functionality yet, just laying it out) that opens with a dialog box with 2 buttons. If you hit one button another Dialog box opens and when you hit OK/Cancel from that Dialog control goes back to the original dialog. If you hit the other button the otherDialog box opens but when you hit OK/Cancel from that dialog, once it closes out and the original dialog box comes back into view, I can't click on the original dialog anymore. It's like it's grayed out. I just hear a ding in the background each time I try to click anywhere on it. I can't see anything that I'm doing differently between the 2. Are there any parenting issues involved here?

    in my header for the main dialog box
    Qt Code:
    1. class cMainWindowDlg : public QDialog, public Ui::cMainWindowDlg
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. cMainWindowDlg(QWidget * parent = 0);
    7. virtual ~cMainWindowDlg();
    8. void setupUi();
    9.  
    10. private slots:
    11. // Automatically connected slots. Note these slots follow the naming convention
    12. // on_objectName_signalName()
    13.  
    14. void on_mOkButton_clicked();
    15. void on_mCancelButton_clicked();
    16. void on_mLaborCategoryButton_clicked();
    17. void on_mContractButton_clicked();
    18.  
    19. private:
    20. cLaborCategoryDlg * mLaborCategoryDlg;
    21. cContractDataQueryDlg * mContractDataDlg;
    22. }; // cMainWindowDlg
    To copy to clipboard, switch view to plain text mode 
    the constructor for main dialog box
    Qt Code:
    1. ////////////////////////////////////////////////////////////////////////////////
    2. cMainWindowDlg::cMainWindowDlg(QWidget * parent) :
    3. QDialog(parent),
    4. mLaborCategoryDlg(0),
    5. mContractDataDlg(0)
    6. {
    7. // Note that setupUi() will also automatically connect any slots that follow
    8. // the naming conventions.
    9. setupUi();
    10.  
    11. mLaborCategoryDlg = new cLaborCategoryDlg(this); //Managed by Qt
    12.  
    13. mContractDataDlg = new cContractDataQueryDlg(this); //Managed by Qt
    14.  
    15. } // cMainWindowDlg::cMainWindowDlg
    16. void cMainWindowDlg::setupUi()
    17. {
    18. Ui_cMainWindowDlg::setupUi(this); // Must call the base class setupUi first
    19.  
    20. } // cMainWindowDlg::setupUi
    To copy to clipboard, switch view to plain text mode 

    the 2 buttons that open up the other dialog boxes
    Qt Code:
    1. void cMainWindowDlg::on_mLaborCategoryButton_clicked()
    2. {
    3. bool accepted(mLaborCategoryDlg->exec())); //true=>OK false=>Cancel
    4. }
    5. void cMainWindowDlg::on_mContractButton_clicked()
    6. {
    7. bool accepted(mContractDataDlg->exec())); //true=>OK false=>Cancel
    8. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDialog ?

    How do you "close" that otherDialog in your code?

  3. #3
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QDialog ?

    do you want to open multiple dialog by clicking first button?

  4. #4
    Join Date
    May 2006
    Posts
    33
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDialog ?

    I close each dialog the same way.

    The one that "works"
    Qt Code:
    1. ////////////////////////////////////////////////////////////////////////////////
    2. void cLaborCategoryDlg::on_mOkButton_clicked()
    3. {
    4. accept();
    5. } // cLaborCategoryDlg::on_mOkButton_clicked
    6.  
    7. ////////////////////////////////////////////////////////////////////////////////
    8. void cLaborCategoryDlg::on_mCancelButton_clicked()
    9. {
    10. reject();
    11. } // cLaborCategoryDlg::on_mCancelButton_clicked
    To copy to clipboard, switch view to plain text mode 

    The one that doesn't:
    Qt Code:
    1. ////////////////////////////////////////////////////////////////////////////////
    2. void cContractDataQueryDlg::on_mOkButton_clicked()
    3. {
    4. accept();
    5. } // cContractDataQueryDlg::on_mOkButton_clicked
    6.  
    7. ////////////////////////////////////////////////////////////////////////////////
    8. void cContractDataQueryDlg::on_mCancelButton_clicked()
    9. {
    10. reject();
    11. } // cContractDataQueryDlg::on_mCancelButton_clicked
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDialog ?

    Have you reimplemented accept(), reject() or exec() in cContractDataQueryDlg?

  6. #6
    Join Date
    May 2006
    Posts
    33
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDialog ?

    No, I haven't.

  7. #7
    Join Date
    May 2006
    Posts
    33
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDialog ?

    I figured it out. In the dialog box that wasn't closing out properly, I had several checkboxes, and for some reason, one of the checkboxes had Qt::ApplicationModal set

    Anyway, set it to Qt::NonModal like all of the rest, and it works fine now.

    Thanks to all who replied.

  8. #8
    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: QDialog ?

    Quote Originally Posted by allensr View Post
    I close each dialog the same way.

    The one that "works"
    Qt Code:
    1. ////////////////////////////////////////////////////////////////////////////////
    2. void cLaborCategoryDlg::on_mOkButton_clicked()
    3. {
    4. accept();
    5. } // cLaborCategoryDlg::on_mOkButton_clicked
    6.  
    7. ////////////////////////////////////////////////////////////////////////////////
    8. void cLaborCategoryDlg::on_mCancelButton_clicked()
    9. {
    10. reject();
    11. } // cLaborCategoryDlg::on_mCancelButton_clicked
    To copy to clipboard, switch view to plain text mode 
    Do you know that these slots are redundant? You might have done:
    Qt Code:
    1. connect(mOkButton, SIGNAL(clicked()), this, SLOT(accept()));
    2. connect(mCancelButton, SIGNAL(clicked()), this, SLOT(reject()));
    To copy to clipboard, switch view to plain text mode 

    Or even make the connection graphically in Designer.

Similar Threads

  1. QDialog margin and spacing
    By TheRonin in forum Qt Programming
    Replies: 4
    Last Post: 29th October 2007, 10:11
  2. QDialog / QListView problem
    By harakiri in forum Qt Programming
    Replies: 1
    Last Post: 10th July 2007, 18:31
  3. Replies: 11
    Last Post: 31st May 2007, 01:11
  4. Resizing a QDialog to the content size
    By Nyphel in forum Qt Programming
    Replies: 8
    Last Post: 15th March 2007, 08:16
  5. Qdialog as a child widget
    By dave in forum Newbie
    Replies: 12
    Last Post: 14th November 2006, 09:43

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.