View Single Post
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#8
Originally Posted by ahmadka View Post
Ok I got another question ...

I'm trying to generate a Dialog box with a custom set of buttons and other controls, but one which looks similar to this:



That is, it pops up from the bottom of the screen in upwards direction, and does not occupy the entire screen (so that you can click outside the popup to hide it away again) ...

However, when I use the following code ...

Code:
QPushButton *b1 = new QPushButton(tr("Yes"));
    QPushButton *b2 = new QPushButton(tr("No"));

    b1->setDefault(true);
    b2->setAutoDefault(false);
    QDialogButtonBox * xx = new QDialogButtonBox(Qt::Vertical);
    xx->addButton(b1,QDialogButtonBox::YesRole);
    xx->addButton(b2,QDialogButtonBox::NoRole);
    xx->setWindowTitle(tr("Testing"));
    xx->setCenterButtons(true);
    xx->show();
... I get the following type of popup:



How can I make it like the first one, such that it doesnt occupy the entire screen, and also 'pops up' from the bottom of the screen ?
You don't appear to have a QDialog at all there, just a QDialogButtonBox. As there's no overall dialog window, or layout manager, then I'm not surprised it looks odd. I'd recommend adding a top-level QDialog, and probably a QHBoxLayout as well (thatt may not be needed for a single widget though).