Important: Please read the Qt Code of Conduct -

How to build widgets from any .ui files created by QtDesigner

  • Hi guys,

    I would like to make something like GUI creator which takes an ui file and creates widgets in it, and show in a window.
    So I have created a button on click I use QFileDialog to get a file.
    And then I would like to use the ui file from QFileDialog to create that gui/widgets and show in a window.

    I have tried QFormbuilder, but it always gives me compile error "undefined reference to `QFormBuilder::QFormBuilder()'"

    Is there a way to do it in qt5?

    Any help appreciated

  • Moderators

    Undefined reference sounds like just missing linker lib. Can you show any code (.pro settings)? You're probably missing something like Qt += widgets or whatever the module the QFormBuilder is in.

  • Hi Chris,

    Here is my code.
    void MainWindow::load()
    QString fname = QFileDialog::getOpenFileName(this, tr("Load file ..."),QDir::currentPath(),tr("UI Files (*.ui)"));

    QFormBuilder loader;
         QFile file("untitled.ui");;
         QWidget *myWidget = loader.load(&file, this);
         QVBoxLayout *layout = new QVBoxLayout;
    QMainWindow *mnw = new QMainWindow();

    I also wanted it to take the file that is loaded by QFileDialog, but it gives also error.

    Any idea what is wrong?

  • Hi,

    I have solved it by adding designer into my .pro file.

    Thanks anyway.

Log in to reply