I'm developing using the Qt Nokia SDK.
I'm having trouble displaying the buttons of a MessageBox, when trying to display a messagebox within a function. If i try to display it within the main window, there is no problem showing the buttons.
The mainwindow consist of a QStackWidget which holds different widgets.
Here is the code that works in main window:
QMessageBox msgBox;
msgBox.setText("Name");
msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard |
QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Save);
int ret = msgBox.exec();
Here is the function and code that i run after receiving a response from a web request (The messagebox displays, but not the buttons.
void MainWindow::RequestReceived()
{
QMessageBox *msgBox = new QMessageBox(this);
msgBox->setText("Test");
msgBox->setWindowModality(Qt::NonModal);
msgBox->setInformativeText("Do you want to save your changes?");
msgBox->setStandardButtons(QMessageBox::Save | QMessageBox::Discard |
QMessageBox::Cancel);
msgBox->setDefaultButton(QMessageBox::Save);
int ret = msgBox->exec();
}
Anyone got an idea of what is happening?
Thanks in advance!
To use the property-based API, construct an instance of QMessageBox, set the desired properties, and call exec() to show the message. The simplest configuration is to set only the message text property. QMessageBox msgBox; msgBox. setText("The document has been modified."); msgBox.
Try this code.It will help you.
QMessageBox Msgbox;
int sum;
sum = ui->textEdit->toPlainText().toInt()+ ui->textEdit_2->toPlainText().toInt();
Msgbox.setText("sum of numbers are...."+sum);
Msgbox.exec();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With