How to position buttons on QMessageBox?
Unsolved
General and Desktop
-
When execute this code, the buttons appears on the rigth.
How can I center the buttons on QMessageBox?QMessageBox msgBox; msgBox.setText("Detener proceso?"); msgBox.setWindowFlags(Qt::FramelessWindowHint); QPushButton *yesButton = msgBox.addButton("Si", QMessageBox::ActionRole); QPushButton *noButton = msgBox.addButton("No", QMessageBox::ActionRole); msgBox.setStyleSheet("QMessageBox QPushButton{" "font-family: Lato Heavy; " "font-weight: bold; " "font-size: 20pt; " "background-color: rgb(50, 50, 50, 255);" "color: white;" "}"); msgBox.setStyleSheet("QMessageBox QLabel{" "color: black; " "}"); msgBox.setStyleSheet("QMessageBox{" "font-family: Lato Heavy; " "font-weight: bold; " "font-size: 15pt; " "background-color: rgb(200, 200, 200, 255);" "}"); msgBox.exec(); if ((QPushButton*)msgBox.clickedButton() == yesButton) { return true; } else if ((QPushButton*)msgBox.clickedButton() == noButton) { return false; }
Thanks.
-
Hi,
You can do simpler: QDialogButtonBox. That class does the work for you.