sara
sara

Reputation: 23

How to make QWidget behave like QMessageBox?

I've been trying to create a QWidget which behave like QMessageBox. When I have for example two QWidget and one QMessageBox until I don't close the QMessageBox I can't available QWidget! Is it exist the function that the QWidget behave like this?

Upvotes: 1

Views: 209

Answers (2)

Géo-IT Solutions
Géo-IT Solutions

Reputation: 25

Derive your widget from QDialog instead of QWidget and call QDialog::setModal() or QDialog::exec().

By the way, a modal non-dialog window is some kind of misdesign.

Upvotes: 0

BBRodriguez
BBRodriguez

Reputation: 326

I'm not sure if I understand you right, but I think you have to call

yourWidget->setWindowModality(Qt::ApplicationModal)

(before showing your Widget) to get the Messagebox-like behaviour...

Upvotes: 2

Related Questions