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. Subdirs and QUiLoader, undefined reference

Subdirs and QUiLoader, undefined reference

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.2k Views 1 Watching
  • 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.
  • E Offline
    E Offline
    Exotic_Devel
    wrote on last edited by
    #1

    I modified my project to subdirs format

    !http://i58.tinypic.com/ven80j.png(MyStructureProject)!

    Now I'm having the error undefined reference to QUiLoader

    @/TecTracker/TecTrackerApp/LoadUi/loadui.cpp:9: error: undefined reference to `QUiLoader::QUiLoader(QObject*)'@

    I've added QT + = uitools the file LoadUi.pro

    @#-------------------------------------------------

    Project created by QtCreator 2014-06-14T15:17:07

    #-------------------------------------------------
    QT += widgets uitools

    QT -= gui

    TARGET = LoadUi
    TEMPLATE = lib
    CONFIG += staticlib

    SOURCES += loadui.cpp

    HEADERS += loadui.hpp
    unix {
    target.path = /usr/lib
    INSTALLS += target
    }
    @

    Below are the other project files

    @

    TecTrackerApp.pro

    TEMPLATE = subdirs

    SUBDIRS +=
    Tests
    LoadUi
    @

    @

    Tests.pro

    #-------------------------------------------------

    Project created by QtCreator 2014-06-14T14:39:32

    #-------------------------------------------------

    INCLUDEPATH += ../LoadUi

    QT += testlib

    QT -= gui

    TARGET = loaduitest
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += ../LoadUi/loadui.cpp
    DEFINES += SRCDIR=\"$$PWD/\"

    HEADERS +=
    loaduitest.hpp
    ../LoadUi/loadui.hpp
    @

    codes

    @
    #ifndef LOADUI_HPP
    #define LOADUI_HPP

    #include <QtWidgets/QWidget>
    #include <QtUiTools/QUiLoader>
    #include <QString>
    #include <QFile>

    class LoadUi
    {
    public:
    explicit LoadUi();
    ~LoadUi();
    QWidget* createForm(const QString, QWidget* = 0);
    };

    #endif
    @

    @
    #include "loadui.hpp"

    LoadUi::LoadUi()
    {
    }

    QWidget *LoadUi::createForm(const QString url, QWidget *parent) // Return object QWidget
    {
    QUiLoader loader;
    QFile ui_file(url);

    ui_file.open(QFile::ReadOnly);
    QWidget* widget = loader.load(&ui_file, parent); // Load .ui file and return pointer for object created
    ui_file.close();

    return widget;
    }
    @

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Since you are rebuilding your libraries sources is the tests you also need to add

      @QT += uitools@

      to Tests.pro

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Exotic_Devel
        wrote on last edited by
        #3

        Perfect!

        But because it was necessary to include in the two project files?

        1 Reply Last reply
        0
        • E Offline
          E Offline
          Exotic_Devel
          wrote on last edited by
          #4

          Another question.

          I already added the path in project file, for files that are in another subdir. But the Creator does not detect the file to include in this way does not trigger the code assistance.

          !http://i57.tinypic.com/33ah06s.png(mycreator)!

          Despite the creator not identify the inclusion, the code compiles without errors.

          1 Reply Last reply
          0
          • E Offline
            E Offline
            Exotic_Devel
            wrote on last edited by
            #5

            By some miracle the creator began to detect

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              It's necessary because you don't use the static lib you are creating but you recompile all the files from it.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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