i have qmessagebox
i'd bigger. it's simple qmessagebox
2 standard buttons, ok , cancel. problem is small application's purposes. code shows this:
qmessagebox msg; msg.settext("whatever"); msg.setstandardbuttons(qmessagebox::ok | qmessagebox::cancel); msg.setsizepolicy(qsizepolicy::expanding,qsizepolicy::expanding); int ret = msg.exec(); switch (ret) { case qmessagebox::ok: ui->textedit->clear(); break; case qmessagebox::cancel: break;}
i tried several ways increase size:
msg.setsizepolicy(qsizepolicy::expanding,qsizepolicy::expanding); msg.setsizepolicy(qsizepolicy::maximum,qsizepolicy::maximum); msg.setfixedheight(600); msg.setfixedwidth(600);
i cleared , rebuilt, , compiles nothing take effect...
do have idea on how set qmessagebox size "by hand"? thanks.
you can edit css of label:
msg.setstylesheet("qlabel{min-width: 700px;}");
you can edit css of buttons add margin or make them bigger.
for example:
msg.setstylesheet("qlabel{min-width:500 px; font-size: 24px;} qpushbutton{ width:250px; font-size: 18px; }");
there trick mentioned:
qspaceritem* horizontalspacer = new qspaceritem(800, 0, qsizepolicy::minimum, qsizepolicy::expanding); qgridlayout* layout = (qgridlayout*)msg.layout(); layout->additem(horizontalspacer, layout->rowcount(), 0, 1, layout->columncount());
but doesn't seem work everyone.