Search code examples
qtstylesheet

rounded buttons of QMessageBox


I am using a QMessagebox to ask if the user wants to close the application.

void MainWindow::closeEvent (QCloseEvent *event)
{
    QMessageBox::StandardButton reply;

    reply = QMessageBox::question(this, "Exit", "Are you sure you want to Exit?",
                                  QMessageBox::Yes|QMessageBox::No);
    if (reply == QMessageBox::Yes)
    {
        event->accept();
    } else {
        event->ignore();
    }
}

I am trying to round the Yes/No buttons by changing the stylesheet to

QMessageBox QPushButton{
border: 1px solid black; border-radius: 10px;
}

however this piece of code changes it to

Rounded Buttons

How do I make the rounded buttons a more proper size?


Solution

  • You have not given it a definite size in the css rule; you have to define the width and height of the buttons or you you simply add a padding so the dimensions will adjust relatively.