ChrisW67
8th July 2009, 00:25
Hi All,
This is a complete noob question and I'm no doubt going to smack my forehead when I hear the answer.
I am creating a QMessageBox in various places to present errors and warnings. The boxes seem to have a mind of their own when it comes to sizing (width) and often wrap poorly or truncate the window title. I have tried using setMinimumWidth() but it does not seem to have any effect. Code looks like:
#include <QtGui>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMessageBox msgBox1;
msgBox1.setMinimumWidth(400); // seemingly ignored, always same width box
msgBox1.setWindowTitle("Width 400");
msgBox1.setText("<strong>Warning</strong>");
msgBox1.setInformativeText(
"You have not entered hours against this event<br /> "
"Do you wish to save the event anyway?");
msgBox1.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox1.setDefaultButton(QMessageBox::No);
msgBox1.setIcon(QMessageBox::Warning);
msgBox1.show();
QMessageBox msgBox2;
msgBox2.setMinimumWidth(800); // seemingly ignored, always same width box
msgBox2.setWindowTitle("Width 800");
msgBox2.setText("<strong>Warning</strong>");
msgBox2.setInformativeText(
"You have not entered hours against this event<br /> "
"Do you wish to save the event anyway?");
msgBox2.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox2.setDefaultButton(QMessageBox::No);
msgBox2.setIcon(QMessageBox::Warning);
msgBox2.exec();
return app.exec();
}
// vi: sw=4 ts=4 et
The result is attached. What is the obvious thing I'm missing?
Chris
This is a complete noob question and I'm no doubt going to smack my forehead when I hear the answer.
I am creating a QMessageBox in various places to present errors and warnings. The boxes seem to have a mind of their own when it comes to sizing (width) and often wrap poorly or truncate the window title. I have tried using setMinimumWidth() but it does not seem to have any effect. Code looks like:
#include <QtGui>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMessageBox msgBox1;
msgBox1.setMinimumWidth(400); // seemingly ignored, always same width box
msgBox1.setWindowTitle("Width 400");
msgBox1.setText("<strong>Warning</strong>");
msgBox1.setInformativeText(
"You have not entered hours against this event<br /> "
"Do you wish to save the event anyway?");
msgBox1.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox1.setDefaultButton(QMessageBox::No);
msgBox1.setIcon(QMessageBox::Warning);
msgBox1.show();
QMessageBox msgBox2;
msgBox2.setMinimumWidth(800); // seemingly ignored, always same width box
msgBox2.setWindowTitle("Width 800");
msgBox2.setText("<strong>Warning</strong>");
msgBox2.setInformativeText(
"You have not entered hours against this event<br /> "
"Do you wish to save the event anyway?");
msgBox2.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox2.setDefaultButton(QMessageBox::No);
msgBox2.setIcon(QMessageBox::Warning);
msgBox2.exec();
return app.exec();
}
// vi: sw=4 ts=4 et
The result is attached. What is the obvious thing I'm missing?
Chris