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. Signal not found error solved by using old connect sythax. Why?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.4k 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.
  • N Offline
    N Offline
    nwoki
    wrote on last edited by
    #1

    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
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      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
      1
      • N Offline
        N Offline
        nwoki
        wrote on last edited by
        #3

        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
        0

        • Login

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