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();
}
但我不能讓QMessageBox提示轉到屏幕的中心,我也嘗試過使用setGeometry,但它不工作。對此有何想法?
'QDesktopWidget win; message-> move(win.width()/ 2,win.height()/ 2);'我使用它,但它仍然出現在0,0。我在想這可能是一個必需品bug – Vordok 2012-02-10 22:51:27
糟糕。沒有注意到Android標籤:) – 2012-02-10 23:04:52