PDA

View Full Version : QMessageBox buttons appearance



yartov
23rd June 2008, 16:33
Hello,
I have a problem with button's appearance in QMessageBox class. When I run my app on Mac, all buttons on message box are higher (bigger vertically) than the buttons on all other applications on Mac. I understand that QPushButton has default maximum height and that max does not match the Mac's standard.
I would like to change the default maximum height in QMessageBox as well as in QProgressDialog. I tried to do that using style sheet, but it did not work. It works for my own forms though, but not for QMessageBox dialog.
Could somebody please give me some hints/suggestions which I can try to fix this problem.
Thanks in advance

jacek
23rd June 2008, 23:23
How do you show the message box?

yartov
24th June 2008, 05:46
I just call static function like the following:
QMessageBox::warning(this, tr("My App"), tr("Please select files to copy."), MessageBox::Ok);

jacek
24th June 2008, 23:40
I see, what style sheet did you try?

yartov
25th June 2008, 03:47
QPushButton
{
max-height : 32px;
}

This supposed to set maximum height to all QPushButtons in my app and it did but only to buttons i use in my ui forms, but not to QMessageBox.

jacek
25th June 2008, 22:23
Could you check if this works on your system?

#include <QApplication>
#include <QMessageBox>
#include <QWidget>
#include <QTimer>

class Test : public QWidget
{
Q_OBJECT
public slots:
void test()
{
QMessageBox::warning( this, tr("My App"), tr("Please select files to copy."), QMessageBox::Ok);
}
};

int main( int argc, char **argv )
{
QApplication app( argc, argv );

app.setStyleSheet( "QPushButton { max-height: 8px; } " );

Test t;
t.show();

QTimer::singleShot( 1000, &t, SLOT(test()) );

return app.exec();
}

#include "main.moc"

yartov
26th June 2008, 01:36
It did work. My problem was that I put the QPushButton style statement into the wrong place in my style sheet. Thanks you very much. Your example made me analyze what is wrong with my style sheet.:D Thanks A LOT.