What do you mean by "unlocking"? Frame by frame? Or one that does not block execution until the user types OK? In both cases, you need to create the QMessageBox manually instead of using convenient static methods like QMessageBox :: critical (), etc.
In both cases, your friends QDialog::open() and QMessageBox::open( QObject*, const char* ) :
void MyWidget::someMethod() { ... QMessageBox* msgBox = new QMessageBox( this ); msgBox->setAttribute( Qt::WA_DeleteOnClose ); //makes sure the msgbox is deleted automatically when closed msgBox->setStandardButtons( QMessageBox::Ok ); msgBox->setWindowTitle( tr("Error") ); msgBox->setText( tr("Something happened!") ); msgBox->setIcon... ... msgBox->setModal( false ); // if you want it non-modal msgBox->open( this, SLOT(msgBoxClosed(QAbstractButton*)) ); //... do something else, without blocking } void MyWidget::msgBoxClosed(QAbstractButton*) { //react on button click (usually only needed when there > 1 buttons) }
Of course, you can wrap this in your own helper functions so you don't have to duplicate it throughout your code.
Frank osterfeld
source share