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. Signals and Slot Isssue Qt 5.7
Qt 6.11 is out! See what's new in the release blog

Signals and Slot Isssue Qt 5.7

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 982 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.
  • H Offline
    H Offline
    herlarbee
    wrote on last edited by
    #1

    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

    jsulmJ 1 Reply Last reply
    0
    • H herlarbee

      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

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @herlarbee Shouldn't it be:

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

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