How to process signals in a Qt subclass?

前端 未结 3 1670
生来不讨喜
生来不讨喜 2021-01-11 17:17

How do I process a signal of in a subclass? Let\'s say my subclass is derived from QTextEdit and is interested in the signal textChanged. It seem

相关标签:
3条回答
  • 2021-01-11 17:33

    It is perfectly ok to connect a signal to a slot in the same class. So implement your slot and connect it to textChanged(QString)

    0 讨论(0)
  • 2021-01-11 17:37

    You can't implement/override a signal, so the only way is to create a new slot and connect it to textChanged():

    connect( this, SIGNAL(textChanged(QString)), this, SLOT(slotTextChanged(QString)) );
    
    0 讨论(0)
  • 2021-01-11 17:59

    Maybe it seems silly, but that's the way I did it : connecting my derived class to the signal emited by the parent class.

    But I'm interested if there are any other solutions !

    0 讨论(0)
提交回复
热议问题