Signals and Slot Isssue Qt 5.7



  • I'm trying to implement a basic signal and slot on the same class but i'm getting an error.
    In my .h file
    #include <QObject>
    class RolePermissions : public QObject
    {
    Q_OBJECT
    // Class have a private access level by default.
    void doPermissionsFlagPopulation();
    private slots:
    void populatePermisionsFlags();

    public:
    explicit RolePermissions(QObject *parent = 0);

    signals:
        NotifyPermissionsClassConstructorCalled();
    

    In.cpp file
    #include "rolepermissions.h"
    #include <QDebug>
    RolePermissions::RolePermissions(QObject *parent) :
    QObject(parent),
    {
    doPermissionsFlagPopulation();
    bool ok = connect(this,this->NotifyPermissionsClassConstructorCalled,this,this->populatePermisionsFlags);
    qDebug()<< ok;
    qDebug()<<"Slot Should have been Fired by now";

    }
    

    void RolePermissions::doPermissionsFlagPopulation()
    {
    emit NotifyPermissionsClassConstructorCalled();
    qDebug()<< "signal Emitted";
    }

    void RolePermissions::populatePermisionsFlags()
    {
    
      qDebug()<< "I'm emitted";
    
    }
    

    BTW the bool flag returns true.
    Is this a bug or am i missing something


  • Moderators

    @herlarbee Shouldn't it be:

    bool ok = connect(this,&RolePermissions::NotifyPermissionsClassConstructorCalled,this,&RolePermissions::populatePermisionsFlags);
    

Log in to reply
 

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