PDA

View Full Version : QMessageBox Size



locus
26th July 2007, 22:30
I am trying to set the size of a message box that i have created as follows:




QMessageBox msgBox(this);
msgBox.setWindowTitle(tr("MailBox Location"));

msgBox.setInformativeText(tr("You must ..... and so on and so forth"));





I have tried the following:




1). msgbox.setGeometry ( int x, int y, int w, int h )

2). msgbox.resize(int w, int h)



and nothing seems to affect the way the box is diplayed, interms of its size that is.

any suggestion is welcomed.


Thanks in advance.

jpn
27th July 2007, 18:09
Looks like QMessageBox::showEvent() forces it to fixed size according to various factors. One ugly way to work it around is:


class MyMessageBox : public QMessageBox {
protected:
void showEvent(QShowEvent* event) {
QMessageBox::showEvent(event);
setFixedSize(640, 480);
}
};

J_Courbon
20th July 2011, 13:35
It seems that reimplementing the function showEvent() is not the good way because a resizeEvent may occur after it. One (still ugly) way is to reimplement the resizeEvent function:


class MyMessageBox : public QMessageBox {
protected:
void resizeEvent(QResizeEvent* event) {
setFixedSize(640, 480);
}
};