I've just started tinkering with QDialog and so just wanted to create one with a button saying "OK" there. The code's the following:
bool MyCanvas::HorizonDialog()
{
dlg->setAttribute(Qt::WA_DeleteOnClose);
ok.setDefault(true);
connect(&ok,SIGNAL(clicked()),dlg,SLOT(close()));
layout.addWidget(&ok);
dlg->setLayout(&layout);
dlg->raise();
dlg->show();
return true;
}
bool MyCanvas::HorizonDialog()
{
QDialog* dlg = new QDialog(this);
dlg->setAttribute(Qt::WA_DeleteOnClose);
QHBoxLayout layout;
QPushButton ok("OK",dlg);
ok.setDefault(true);
connect(&ok,SIGNAL(clicked()),dlg,SLOT(close()));
layout.addWidget(&ok);
dlg->setLayout(&layout);
dlg->raise();
dlg->show();
return true;
}
To copy to clipboard, switch view to plain text mode
I want the dialog to be modeless, so I chose to use QDialog::show() instead of ::exec(). However, when I run the program, the pushbutton doesn't appear. Should I use QDialog::exec(), however, the button does appear and everything works fine. I've tried "ok.show()" both before and after "dlg->show()" and neither worked.
Help?
Bookmarks