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. Is it possible a derived class object can emit a signal base class
QtWS25 Last Chance

Is it possible a derived class object can emit a signal base class

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 2.7k 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by VRonin
    #1

    Hi All
    I have a base class

      class A {
          Q_Object:
       public:
         signals
            updateUndoRedoActionDone(bool);
    
      
    
    };
    
    class B : public A {
        
       public :
          void task:
    
    };
    
    void B::task() {
        connect::(this , updateUndoRedoActionDone,otherObject, udateUndoRedoInPhysicalView);
    
    }
    
    void B::signal() {
    
       emit updateUndoRedoActionDone(false);
    }
    

    The derived object has not has Q_object

    jsulmJ 1 Reply Last reply
    0
    • Q Qt Enthusiast

      Hi All
      I have a base class

        class A {
            Q_Object:
         public:
           signals
              updateUndoRedoActionDone(bool);
      
        
      
      };
      
      class B : public A {
          
         public :
            void task:
      
      };
      
      void B::task() {
          connect::(this , updateUndoRedoActionDone,otherObject, udateUndoRedoInPhysicalView);
      
      }
      
      void B::signal() {
      
         emit updateUndoRedoActionDone(false);
      }
      

      The derived object has not has Q_object

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

      @Qt-Enthusiast Sure it is possible, but B needs Q_OBJECT.

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

      1 Reply Last reply
      3

      • Login

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