Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved Signal not found error solved by using old connect sythax. Why?

    General and Desktop
    2
    3
    1056
    Loading More Posts
    • 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.
    • N
      nwoki last edited by

      Hi all!

      As the title says, I've encountered a problem with Qt's signal/slots. I have a QQmlExtensionPlugin (Exercise) where I need to connect to its own signals in order to start/stop a timer. Now, I wanted to do it like I've been doing for some time now, with:

      connect(this, &Exercise::statusChanged, this, &Exercise::startStopElapsedPausedTimer);
      

      NOTE: arguments match (there aren't any)

      but I encountered the following error during runtime:

      QObject::connect: signal not found in Exercise
      QObject::connect: signal not found in Exercise
      

      After banging my head around and checking my code, I tried to change the signal/slot synthax with the following:

      connect(this, SIGNAL(statusChanged()), this, SLOT(startStopElapsedPausedTimer()));
      

      et voilà! No more connection error at runtime. Can anyone explain this to me? What's happening here? The wiki doesn't say anything about behaviour changes when adopting the new sythax

      1 Reply Last reply Reply Quote 0
      • VRonin
        VRonin last edited by

        could you show the definition of Exercise?

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply Reply Quote 1
        • N
          nwoki last edited by

          The QQmlExtensionPlugin

          .h

          #ifndef EXERCISESETTINGSPLUGIN_H
          #define EXERCISESETTINGSPLUGIN_H
          
          #include <QtQml/QQmlExtensionPlugin>
          
          class Q_DECL_EXPORT ExerciseSettingsPlugin : public QQmlExtensionPlugin
          {
              Q_OBJECT
              Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
          
          public:
              void registerTypes(const char *uri);
          };
          
          #endif // EXERCISESETTINGSPLUGIN_H
          

          .cpp

          #include "exercise.h"
          #include "exercisesettingsplugin.h"
          
          #include <QtQml/QQmlComponent>
          
          void ExerciseSettingsPlugin::registerTypes(const char *uri)
          {
              int versionMajor = 0;
              int versionMinor = 1;
          
              Q_UNUSED (versionMajor);
              Q_UNUSED (versionMinor);
          
              Q_ASSERT(uri == QLatin1String("nirvana.qml.exercisesettings"));
              qmlRegisterType<Exercise>(uri, versionMajor, versionMinor, "Exercise");
          }
          

          and Exercise .h

          #ifndef EXERCISE_H
          #define EXERCISE_H
          
          #include <QtCore/QObject>
          
          class Q_DECL_EXPORT Exercise : public QObject
          {
              Q_OBJECT
          
              // list of properties
          
          public:
              Exercise(QObject *parent = 0);
              Exercise(Exercise *ex);
              virtual ~Exercise();
          
          
          Q_SIGNALS:
              void statusChanged();
          
          private Q_SLOTS:
              void startStopElapsedPausedTimer();
          
          private:
              void setupTimerConnections();
          
          
              class Private;
              Private * const d;
          };
          
          #endif // EXERCISE_H
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post