Dialog box with Proceed and Cancel buttons
Unsolved
General and Desktop
-
I have created my own dialog box.
class CWarningDialog : public QDialog
I have also created a couple of buttons, ok and cancel, via code
QPushButton *BUTTONProcess; //This is like a Ok button QPushButton *BUTTONCancel;
Under MFC, I gave the Proceed button the ID of IDOK and Cancel is IDCANCEL.
So, when Proceed or Cancel is pressed, I get an integer returned by the DoModal() member function.What is the Qt equivalent code to this?
//MFC version int returnVal; returnVal=adlg_WarningDialog.DoModal(); if(returnVal==IDCANCEL) { } //My Qt equivalent code int returnVal; returnVal=adlg_WarningDialog.exec(); if(returnVal) { }
-
Hi,
See QDialog::DialogCode.
-
I got it working.
void CWarningDialog::OnButtonProceed() { accept(); } void CWarningDialog::OnButtonCancel() { reject(); }
and in my main window code
int returnVal; returnVal=adlg_WarningDialog.exec(); if(returnVal==QDialog::Rejected) { }
-
These two custom slots are overkill. You can directly connect your buttons to the appropriate accept/reject slots.