Dear All,
I have managed to show "Don't show message again" check box on QMessageBox in Qt 4.7.3 but now problem is the moment I clicks on check box it terminates message box and I don't want it.
I wanted to mark the check box only, please help if anyone has any idea.
Here is the sample code.
msgBox.setText(WMC_ASSIGNMENT_OVERWRITE_MSG);
QCheckBox dontShowCheckBox
("don't show this message again");
dontShowCheckBox.setCheckable(true);
msgBox.
addButton(&dontShowCheckBox,
QMessageBox::ApplyRole);
int32_t userReply = msgBox.exec();
QMessageBox msgBox;
msgBox.setText(WMC_ASSIGNMENT_OVERWRITE_MSG);
msgBox.setIcon(QMessageBox::Warning);
QCheckBox dontShowCheckBox("don't show this message again");
dontShowCheckBox.setCheckable(true);
msgBox.addButton(&dontShowCheckBox, QMessageBox::ApplyRole);
msgBox.addButton(QMessageBox::Ok);
msgBox.addButton(QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
int32_t userReply = msgBox.exec();
To copy to clipboard, switch view to plain text mode
Added after 1 8 minutes:
Dear All,
Finally, I managed to get what I wanted and here is the sample code of QMessageBox with "Don't show this message box again" check box in Qt 4.7.3.
msgBox.setText("Sample message text");
QCheckBox dontShowCheckBox
("don't show this message again");
dontShowCheckBox.blockSignals(true);
msgBox.
addButton(&dontShowCheckBox,
QMessageBox::ResetRole);
int32_t userReply = msgBox.exec();
{
if(dontShowCheckBox.checkState() == Qt::Checked)
{
//Write function to handle this use case.
}
}
QMessageBox msgBox;
msgBox.setText("Sample message text");
msgBox.setIcon(QMessageBox::Warning);
msgBox.addButton(QMessageBox::Ok);
msgBox.addButton(QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
QCheckBox dontShowCheckBox("don't show this message again");
dontShowCheckBox.blockSignals(true);
msgBox.addButton(&dontShowCheckBox, QMessageBox::ResetRole);
int32_t userReply = msgBox.exec();
if(userReply == QMessageBox::Ok)
{
if(dontShowCheckBox.checkState() == Qt::Checked)
{
//Write function to handle this use case.
}
}
To copy to clipboard, switch view to plain text mode
Thank you.
Bookmarks