I want to move the Cancel button of QProgressDialog
to the center; by default its on the left.
Below is a simple example, but I don't know how to change the button position.
_progress = new QProgressDialog();
_progress->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
_progress->setWindowTitle(tr("Stimulated Movement"));
_progress->setLabelText(tr("Please wait for a moment while the motor is moving!"));
_progress->setAttribute(Qt::WA_DeleteOnClose);
_progress->setModal(true);
//make it Keep rolling
_progress->setRange(0, 0);
_progress->setCancelButton(new QPushButton(tr("Terminate")));
Remy Lebeau said:
Here's how you can implement that:
However there is a problem with this method, the button will not stay in the center if the dialog is resized.
Fixing that, needs
resizeEvent
reimplementation, but if you don't need resizing, you might just want to set a fixed size for the dialog to prevent it.For example: