I have this
int MainWindow::messageBox( QString button, QMessageBox::ButtonRole buttons, QString info, QMessageBox::Icon icon )
{
QFont f;
f.setPointSize(6);
QMessageBox *message = new QMessageBox(this);
message->setWindowModality(Qt::WindowModal);
message->setFont(f);
message->setText(info);
message->addButton( button, buttons );
message->setWindowTitle("MainWindow");
message->setIcon(icon);
message->move( this->width() / 2, this->height() / 2 );
return message->exec();
}
But I can’t make the qmessagebox go to the center of the screen, I also tried using setGeometry, but it doesn’t work. Any ideas on this?
I solved using show() before moving it. This is the code: