Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Linker error with custom widgets
Forum Updated to NodeBB v4.3 + New Features

Linker error with custom widgets

Scheduled Pinned Locked Moved Qt Creator and other tools
5 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.
  • T Offline
    T Offline
    tanmay2227
    wrote on last edited by
    #1

    hey i am getting a linker error when installing a custom widget
    plus my widget is not visible in qtcreator and only visible in qt designer . please help me . i have used qt5.0 in win 7 and msvc compiler

    linker errors are of this kind
    mainwindow.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall AnalogClock::AnalogClock(class QWidget *)" (_imp??0AnalogClock@@QAE@PAVQWidget@@@Z) referenced in function "public: void __thiscall Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi@Ui_MainWindow@@QAEXPAVQMainWindow@@@Z)

    please help

    Tanmay Priyadarshi

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tilsitt
      wrote on last edited by
      #2

      Hi,

      It looks like the symbols have not been exported when compiling AnalogClock. Could you please show the class declaration?

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tanmay2227
        wrote on last edited by
        #3

        #include <QDesignerCustomWidgetInterface>

        class AnalogClockPlugin : public QObject, public QDesignerCustomWidgetInterface
        {
        Q_OBJECT
        Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface" FILE "analogclock.json")
        Q_INTERFACES(QDesignerCustomWidgetInterface)
        public:
        AnalogClockPlugin(QObject *parent = 0);

        bool isContainer() const;
        bool isInitialized() const;
        QIcon icon() const;
        QString domXml() const;
        QString group() const;
        QString includeFile&#40;&#41; const;
        QString name(&#41; const;
        QString toolTip() const;
        QString whatsThis() const;
        QWidget *createWidget(QWidget *parent);
        void initialize(QDesignerFormEditorInterface *core);
        

        private:
        bool initialized;
        };


        though this is same as the custom widgetsexample of qt i have tried various versions but none are working
        this is the pro file of my executing file


        QT += core gui

        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

        TARGET = tester
        TEMPLATE = app

        SOURCES += main.cpp
        mainwindow.cpp

        HEADERS += mainwindow.h

        FORMS += mainwindow.ui
        INCLUDEPATH += "C:\Qt\Qt5.0.1\5.0.1\msvc2010\examples\designer\customwidgetplugin"


        i had also added the libs path but on that the program terminates without any reason


        LIBS +=-L"C:\Qt\Qt5.0.1\Tools\QtCreator\bin\tester" -l"customwidgetplugin"

        Tanmay Priyadarshi

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tilsitt
          wrote on last edited by
          #4

          If you try this:
          @
          #ifdef EXPORT_MY_PLUGIN
          #define MY_API Q_DECL_EXPORT
          #else
          #define MY_API Q_DECL_IMPORT
          #endif

          class MY_API AnalogClockPlugin
          ...
          @

          while adding EXPORT_MY_PLUGIN in the defines of your plugin project, does it change something?

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tanmay2227
            wrote on last edited by
            #5

            no the file is not compiling even and well the code is actually qt example only
            so i think it is the deployment and installing which is the problem

            Tanmay Priyadarshi

            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