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. (SOLVED) custom widget collection, LNK2019, LNK1120 problem.

(SOLVED) custom widget collection, LNK2019, LNK1120 problem.

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.9k 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.
  • C Offline
    C Offline
    CKM80
    wrote on last edited by CKM80
    #1

    Hello.

    I made a custom widget collection with the Qt Custom Designer Widget Project.
    (windows7, Qt5.4.1 MSVC 2010 32bit, Qt Creator3.3.1)

    I can see custom widgets in Qt creator designer and drag it on the mainwindow.ui.

    Now, I have a dll, a lib and three .h files for custom button, checkbox, combobox at 'lib' folder.

    (folder structure)
    untitied2 |- lib -|- snmscontrolfactoryplugin.dll
    untitied2 |- lib -|- snmscontrolfactoryplugin.lib
    untitied2 |- lib -|- snmsqcheckbox.h
    untitied2 |- lib -|- snmsqcombobox.h
    untitied2 |- lib -|- snmsqpushbutton.h
    untitied2 |- main.cpp
    untitied2 |- mainwindow.cpp
    untitied2 |- mainwindow.h
    untitied2 |- mainwindow.ui
    untitied2 |- unittiled2.pro

    (.pro)
    QT += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    TARGET = untitled2
    TEMPLATE = app

    INCLUDEPATH += $$PWD/lib/
    LIBS += -L$$PWD/lib -lsnmscontrolfactoryplugin

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h
    FORMS += mainwindow.ui

    then, I got this message

    mainwindow.obj : error LNK2019: "public: __thiscall SNMSQComboBox::SNMSQComboBox(class QWidget *)" (??0SNMSQComboBox@@QAE@PAVQWidget@@@Z) 외부 기호(참조 위치: "public: void __thiscall Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi@Ui_MainWindow@@QAEXPAVQMainWindow@@@Z) 함수)에서 확인하지 못했습니다.
    mainwindow.obj : error LNK2019: "public: __thiscall SNMSQCheckBox::SNMSQCheckBox(class QWidget *)" (??0SNMSQCheckBox@@QAE@PAVQWidget@@@Z) 외부 기호(참조 위치: "public: void __thiscall Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi@Ui_MainWindow@@QAEXPAVQMainWindow@@@Z) 함수)에서 확인하지 못했습니다.
    mainwindow.obj : error LNK2019: "public: __thiscall SNMSQPushButton::SNMSQPushButton(class QWidget *)" (??0SNMSQPushButton@@QAE@PAVQWidget@@@Z) 외부 기호(참조 위치: "public: void __thiscall Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi@Ui_MainWindow@@QAEXPAVQMainWindow@@@Z) 함수)에서 확인하지 못했습니다.
    release\untitled2.exe : fatal error LNK1120: 3개의 확인할 수 없는 외부 참조입니다.

    how can I resolve it?

    (SOLVED)
    I found a solution.
    The Qt Custom Designer Widget Project doesn't make the dll macro in the header file.
    So, need to include dll export macro in each header file like this.

    #include <QtDesigner/QtDesigner>
    #include <QPushButton>
    class QDESIGNER_WIDGET_EXPORT SNMSQPushButton : public QPushButton
    {
    ~~
    ~~
    ~~
    }

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

      Hi and welcome to devnet,

      Is snmscontrolfactoryplugin built with MSVC2010 32bit ?

      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
      • C Offline
        C Offline
        CKM80
        wrote on last edited by
        #3

        Hi~ SGaist.
        Yes, I built with MSVC2010 32bit.

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

          You should use your own version of that macro. You might very well build your project against a Qt where designer wasn't built.

          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