Public functions versus public slots

前端 未结 5 1165
情话喂你
情话喂你 2021-01-02 07:45

In my one year of Qt programming, I have learnt a lot about signals and slots. But not enough...

http://doc.qt.io/qt-5/signalsandslots.html

S

5条回答
  •  难免孤独
    2021-01-02 07:46

    Another use case where you possibly don't want all methods to be slots is when you are exposing objects to JavaScript through Qt's WebKit Bridge: all public slots are invocable from the JavaScript and that might open up security issues, depending on whether the JavaScript can be trusted or not.

    So if you want a public method which is not invocable from JavaScript, you may not declare it as a slot.

提交回复
热议问题