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



  • 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



  • could you show the definition of Exercise?



  • 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
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.