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. Link Error By Q_OBJECT

Link Error By Q_OBJECT

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 2.7k 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.
  • jronaldJ Offline
    jronaldJ Offline
    jronald
    wrote on last edited by jronald
    #1

    EvaluateWidget .h

    #ifndef EVALUATEWIDGET_H
    #define EVALUATEWIDGET_H
    
    #include <QtTreePropertyBrowser>
    
    class EvaluateWidget : public QtTreePropertyBrowser
    {
        Q_OBJECT
    public:
        EvaluateWidget(QWidget * parent = 0);
    };
    
    #endif // EVALUATEWIDGET_H
    

    EvaluateWidget .cpp

    #include "EvaluateWidget.h"
    EvaluateWidget::EvaluateWidget(QWidget * parent) : QtTreePropertyBrowser(parent)
    {
    
    }
    

    Link error:

    moc_EvaluateWidget.obj:-1: error: LNK2001: unresolved external symbol "public: static struct QMetaObject const QtTreePropertyBrowser::staticMetaObject" (?staticMetaObject@QtTreePropertyBrowser@@2UQMetaObject@@B)
    

    Env:

    Desktop_Qt_5_9_1_MSVC2017_64bit
    Qt Creator 4.3.1
    

    If Q_OBJECT is removed, everything is OK.
    Any way to solve the problem?

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

      @jronald said in Link Error By Q_OBJECT:

      LNK2001: unresolved external symbol "public: static struct QMetaObject

      Hi
      Step one is to delete the build folder and rebuild
      if that dont help then, remove Q_OBJECT and add it again

      https://stackoverflow.com/questions/14170770/unresolved-external-symbol-public-virtual-struct-qmetaobject-const-thiscal

      Also check the moc_* files are being generated.

      1 Reply Last reply
      1
      • jronaldJ Offline
        jronaldJ Offline
        jronald
        wrote on last edited by jronald
        #3

        I've already searched the web, and tried hard, but no help.

        If replace QtTreePropertyBrowser with QWidget, no error.

        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #4

          Hi, googling "unresolved external symbol "public: static struct QMetaObject const QtTreePropertyBrowser" returns this 7 year old bug
          At the end it says adding the symbol QT_QTPROPERTYBROWSER_IMPORT to your build environment should help.

          1 Reply Last reply
          3
          • jronaldJ Offline
            jronaldJ Offline
            jronald
            wrote on last edited by
            #5

            Solved!
            Thanks very much.

            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