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. How to override timeout() signal of qtimer or any other signal in our class?
Forum Updated to NodeBB v4.3 + New Features

How to override timeout() signal of qtimer or any other signal in our class?

Scheduled Pinned Locked Moved General and Desktop
qtimerqt5c++signalsignal & slotqtcreator
3 Posts 3 Posters 3.4k Views 2 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.
  • P Offline
    P Offline
    Piyush_Ashtikar
    wrote on last edited by
    #1

    How to override timeout() signal of qtimer or any other signal in our class or any other signal.
    Also how to use both overridden signal and base signal ?

    JKSHJ 1 Reply Last reply
    0
    • P Piyush_Ashtikar

      How to override timeout() signal of qtimer or any other signal in our class or any other signal.
      Also how to use both overridden signal and base signal ?

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi @Piyush_Ashtikar, and welcome to the Qt Dev Net!

      How to override timeout() signal of qtimer or any other signal in our class or any other signal.
      Also how to use both overridden signal and base signal ?

      What do you mean by "override a signal"? Signals don't contain any functions -- they only call slots.

      Do you mean "override a slot"?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • P Offline
        P Offline
        PleaseWait
        wrote on last edited by
        #3

        Hi there,

        I'm not completely sure what you are asking. But if I'm understanding you correctly, you
        want to implement the timeout() signal in your own way? I would suggest sub-classing the
        QTimer object.

        #include <QTimer>
        
        class CustomTimer : public QTimer
        {
            Q_OBJECT
        public:
            explicit CustomTimer(QObject *parent = 0);
        
        signals:
            void customSignal(/*parameters*/);
            
        public slots:
            void emitCustomSignal();
        };
        
        CustomTimer::CustomTimer(QObject *parent) :
            QTimer(parent)
        {
        
            connect(this, SIGNAL(timeout()), this, SLOT(emitCustomSignal()));
        }
        
        void CustomTimer::emitCustomSignal()
        {
            emit customSignal(/*parameters*/);
        }
        
        
        1 Reply Last reply
        0

        • Login

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