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?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.3k 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.
  • N Offline
    N Offline
    nwoki
    wrote on 3 Feb 2017, 17:13 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
    • V Offline
      V Offline
      VRonin
      wrote on 3 Feb 2017, 19:38 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 4 Feb 2017, 10:56 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

        1/3

        3 Feb 2017, 17:13

        • Login

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