QT: load .ui at run time

    技术2022-05-13  4

    Dynamic dialogs are dialogs that are created from Qt Designer .ui files at run-time. Instead of convertingthe .ui file to C++ code using uic, we can load the file at run-time using the QUiLoader class:

     

    QUiLoader uiLoader;QFile file("sortdialog.ui");QWidget *sortDialog = uiLoader.load(&file);if (sortDialog) {...}

     

    We can access the form's child widgets using QObject::findChild<T>():QComboBox *primaryColumnCombo =sortDialog->findChild<QComboBox *>("primaryColumnCombo");if (primaryColumnCombo) {...}


    最新回复(0)