Sending signal from static class method in Qt

后端 未结 4 568
有刺的猬
有刺的猬 2020-12-29 09:08

I am trying to code a static callback function that is called frequently from another static function within the same class. My callback function needs to emit

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-29 09:26

    You must provide a pointer to the class instance in order to make it work.

    Notice however that in general it is not advised to emit signals from static functions. Static functions can be called without creating an instance of the class, which means that (if you do not provide as argument the sender and use it explicitely), you will not have a "sender" object for the emited signals.

    For these cases as Lol4t0 suggests I also prefer callbacks.

提交回复
热议问题