#include <QApplication>
#include <QMessageBox>
#include <QtUiTools/QtUiTools>
#include <iostream>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QUiLoader loader;
QFile file("ui.ui");
QWidget* ui = loader.load(&file);
if(ui)
{
foreach(QString name,loader.availableWidgets())
std::cout<<qPrintable(name)<<std::endl;
ui->show();
}
else
{
QMessageBox::information(NULL,"Error","Load ui script failed");
}
return app.exec();
}
有时候动态载入控件还是很有必要的