Dynamic dialogs are dialogs that are created from Qt Designer .ui files at run-time. Instead of converting
the .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) {
...
}
本文介绍如何使用Qt的QUiLoader类在运行时从.ui文件加载动态对话框,避免将.ui文件转换为C++代码。文中展示了如何创建对话框实例并获取其子组件。
2445

被折叠的 条评论
为什么被折叠?



