c++ - Why can't I set my QDialog to have no sizeGrip? -
according qt4 docs qdialog's sizegrip disabled default, mine has 1 anyways. try running setsizegripenabled(false) , still have one. so, else must causing this, don't know what. if matters dialog box has no parent because i'm designing/testing it. don't see why should matter, mentioning in case reason. here's full code:
#include "qtgui" //#include "clposter.h" void add_new_account() { // check::make sure process destroyed when it's supposed // todo::connect signals slots // // create dialog box add user account qdialog *accountdialog = new qdialog(); accountdialog->setmodal(true); accountdialog->setwindowtitle("add new account"); accountdialog->setsizegripenabled(false); // create main layout qvboxlayout *mainvbox = new qvboxlayout(accountdialog); qlabel *accountnamelabel = new qlabel(accountdialog); accountnamelabel->settext("account:"); qlineedit *accountname = new qlineedit(accountdialog); accountname->setminimumwidth(250); qlabel *accountpasslabel = new qlabel(accountdialog); accountpasslabel->settext("password:"); qlineedit *accountpass = new qlineedit(accountdialog); accountpass->setechomode(qlineedit::password); // note::may want use standard dialog buttons instead qpushbutton *okbutton = new qpushbutton("ok", accountdialog); qpushbutton *cancelbutton = new qpushbutton("cancel", accountdialog); // connect signals slots // set layout // check::should accountdialog parent these? warning cannot set // because accountdialog has layout, expected, want them // automatically deleted when accountdialog makes sense make parent. qvboxlayout *labelsvbox = new qvboxlayout(accountdialog); labelsvbox->addwidget(accountnamelabel); labelsvbox->addwidget(accountpasslabel); qvboxlayout *lineeditsvbox = new qvboxlayout(accountdialog); lineeditsvbox->addwidget(accountname); lineeditsvbox->addwidget(accountpass); qhboxlayout *tophbox = new qhboxlayout(accountdialog); tophbox->addlayout(labelsvbox); tophbox->addlayout(lineeditsvbox); qhboxlayout *buttonhbox = new qhboxlayout(accountdialog); buttonhbox->addstretch(); buttonhbox->addwidget(okbutton); buttonhbox->addwidget(cancelbutton); mainvbox->addlayout(tophbox); mainvbox->addlayout(buttonhbox); accountdialog->setlayout(mainvbox); // show dialog accountdialog->exec(); } int main(int argc, char *argv[]) { qapplication app(argc, argv); //clposter mainwin; //mainwin.show(); add_new_account(); return app.exec(); }
setting parent should not affect anything.
you can around setting dialog fixed size using setfixedsize(width, height);
however work around.
Comments
Post a Comment