QMessageBox & QCheckBox problem
Hi everyone
I need to place a check box in a message box and I try to do it like this
Code:
0, this, Qt::Sheet);
QCheckBox dontPrompt
("Do not prompt again",
&msgBox
);
msgBox.
addButton(&dontPrompt,
QMessageBox::ActionRole);
pOK->setMaximumSize(200, 31);
pOK->setMinimumSize(70, 31);
msgBox.exec();
But when I click a check Box the message box closes :confused:
Its very strange because I set Button role to QMessageBox::ActionRole which is
Quote:
QMessageBox::ActionRole - Clicking the button causes changes to the elements within the dialog, without closing the dialog.
Re: QMessageBox & QCheckBox problem
Re: QMessageBox & QCheckBox problem
Its not possible to do this with vanilla Qt? :confused:
Re: QMessageBox & QCheckBox problem
you can add checkBox via
Code:
msgBox.layout()->addWidget()
, but it's not good idea.:)
Re: QMessageBox & QCheckBox problem
Here a solution I found
Code:
// HACK: BLOCKING SIGNALS SO QMessageBox WON'T CLOSE
dontPrompt.blockSignals(true);
msgBox.
addButton(&dontPrompt,
QMessageBox::ActionRole);
msgBox.exec();
if ( dontPrompt.checkState() == Qt::Checked )
{
// TODO: YOUR CODE HERE
}
It works for me :)