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. Unresolved external symbol signal
Forum Updated to NodeBB v4.3 + New Features

Unresolved external symbol signal

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 3.6k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on 21 Dec 2015, 18:00 last edited by A Former User
    #1

    I created an instance of QGuiApplication and a signal in order test if it works and I always get that the compiler could not resolve external symbols:

    test.hpp:

    #ifndef TEST_HPP
    #define TEST_HPP
    
    #include <QGuiApplication>
    
    class test : public QGuiApplication
    {
    
    public:
      explicit test(int &argc, char **argv);
    
    signals:
      void signalTest();
    };
    
    #endif // TEST_HPP
    

    test.cpp:

    #include "test.hpp"
    
    test::test(int &argc, char **argv) : QGuiApplication(argc, argv)
    {
      emit signalTest();
    }
    

    I tried to clean the build, remove the built files and build again, and nothing.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 21 Dec 2015, 18:08 last edited by mrjj
      #2

      add Q_OBJECT to your class
      class test : public QGuiApplication
      {
      Q_OBJECT

      and clean, and rebuild all

      All classes that uses signals&slots must have this

      ? 1 Reply Last reply 21 Dec 2015, 18:20
      2
      • M mrjj
        21 Dec 2015, 18:08

        add Q_OBJECT to your class
        class test : public QGuiApplication
        {
        Q_OBJECT

        and clean, and rebuild all

        All classes that uses signals&slots must have this

        ? Offline
        ? Offline
        A Former User
        wrote on 21 Dec 2015, 18:20 last edited by
        #3

        @mrjj That is weird, I tried and I got a lot of errors before, maybe because I needed to delete/clean first.
        I thought that Q_OBJECT was only supposed to be used with QObject classes.

        Thank you, it is solved.

        M 1 Reply Last reply 21 Dec 2015, 18:24
        0
        • ? A Former User
          21 Dec 2015, 18:20

          @mrjj That is weird, I tried and I got a lot of errors before, maybe because I needed to delete/clean first.
          I thought that Q_OBJECT was only supposed to be used with QObject classes.

          Thank you, it is solved.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 21 Dec 2015, 18:24 last edited by mrjj
          #4

          @Minupi
          well the Q_OBJECT is used by the moc.exe compiler and sometimes its
          a bit lazy it seems. so when anything else fails, i delete the build folder :)
          Well, its need for the meta system used for signals.
          But frankly I never tried to make a QApplication subclass but normally that the
          case with all other subclassing.
          Update: QApplication is a QCoreApplication which inherits from QObject

          ? 1 Reply Last reply 21 Dec 2015, 18:27
          1
          • M mrjj
            21 Dec 2015, 18:24

            @Minupi
            well the Q_OBJECT is used by the moc.exe compiler and sometimes its
            a bit lazy it seems. so when anything else fails, i delete the build folder :)
            Well, its need for the meta system used for signals.
            But frankly I never tried to make a QApplication subclass but normally that the
            case with all other subclassing.
            Update: QApplication is a QCoreApplication which inherits from QObject

            ? Offline
            ? Offline
            A Former User
            wrote on 21 Dec 2015, 18:27 last edited by
            #5

            @mrjj You are right about being a bit lazy. I need to delete the build folder as well sometimes, specially when creating a new class, for sure I will get errors and I need to delete the folder and build again.

            M 1 Reply Last reply 21 Dec 2015, 18:32
            1
            • ? A Former User
              21 Dec 2015, 18:27

              @mrjj You are right about being a bit lazy. I need to delete the build folder as well sometimes, specially when creating a new class, for sure I will get errors and I need to delete the folder and build again.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 21 Dec 2015, 18:32 last edited by
              #6

              @Minupi
              note. sometimes running qmake will also work.
              It my understanding that "make file" calls moc.exe
              But i have had cases where it would first like after I deleted build folder.
              (regardless of clean/qmake/rebuild all)

              1 Reply Last reply
              1

              3/6

              21 Dec 2015, 18:20

              • Login

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