Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to build widgets from any .ui files created by QtDesigner
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Amry
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Amry
        wrote on last edited by
        #3

        Hi Chris,

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

        QFormBuilder loader;
             QFile file("untitled.ui");
             file.open(QFile::ReadOnly);
             QWidget *myWidget = loader.load(&file, this);
             file.close();
        
             QVBoxLayout *layout = new QVBoxLayout;
             layout->addWidget(myWidget);
             setLayout(layout);
        
        
        QMainWindow *mnw = new QMainWindow();
        mnw->setCentralWidget(myWidget);
        mnw->show();
        

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

        Any idea what is wrong?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Amry
          wrote on last edited by
          #4

          Hi,

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

          Thanks anyway.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved