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 Update on Monday, May 27th 2025

Unresolved external symbol signal

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 3.5k Views
  • 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 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
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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
      2
      • mrjjM mrjj

        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 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.

        mrjjM 1 Reply Last reply
        0
        • ? A Former User

          @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.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on 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
          1
          • mrjjM mrjj

            @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 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.

            mrjjM 1 Reply Last reply
            1
            • ? A Former User

              @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.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on 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

              • Login

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