Using any c++ function as a Qt slot

后端 未结 5 1102
太阳男子
太阳男子 2021-01-17 11:54

Is there a way to use any C++ function as a Qt slot, without having its class inheriting from QWidget?

5条回答
  •  囚心锁ツ
    2021-01-17 12:28

    In Qt 5, you can. See http://qt-project.org/wiki/New_Signal_Slot_Syntax

    In Qt 4, this is not directly supported but there are a couple of libraries which provide this functionality by proxying the signal via a slot in a hidden QObject which then calls your non-slot function. My attempt at this can be found at https://github.com/robertknight/qt-signal-tools . There are links to other implementations on the bottom of the README.

提交回复
热议问题