Dynamic QWidget from QtDesigner form
-
What I am doing wrong? I need dynamic QWidget with form created in QtDesigner. It is heavily decorated dialog therefore I cannot use QMessageBox. All code works but widget does not appear visible. It appears invisible and blocks underlaying widgets (form is Application Modal).
void SomeClass::dialog(const QString& text) { if( Dlg == Q_NULLPTR ) { Dlg = new QWidget((QWidget*)parent()); //parent() here is QMainWindow's centralWidget ui->setupUi( Dlg ); // ui is common QtDesigner form, it's Ok Dlg->raise(); Dlg->update(); connect( ui->okButton, SIGNAL(pressed()), this, SLOT(dialogYes()) ); connect( ui->noButton, SIGNAL(pressed()), this, SLOT(dialogNo()) ); } ui->messageText->setText( text ); Dlg->show(); }
I remember that I did this years ago - and all worked fine. But may be something changed in latest Qt versions (or I forget do something).
-
@jsulm but in designer I have created just only UI XML file. And automatically generated ui_form.h file containing form init code. It requires QWidget to be shown.
Can you tell why I do not see form with my code? If not - then show other solution completely, not only idea. I am straight on my code for while.
-
@Gourmet I don't know why it is not visible. You could try the simple example from the doc with our ui to see whether it is visible:
int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget widget; Ui::YOUR_UI_HERE ui; ui.setupUi(&widget); widget.show(); return app.exec(); }
Also you wrote: "It is heavily decorated dialog". What do you mean with "decorated"? Style-sheets?