Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Q_INVOKABLE vs. slots



  • I'm just curious, is it more lightweight to mark a method with Q_INVOKABLE than as a slot?

    Is it more of a design question to mark a method with Q_INVOKABLE, for instance a method that calculates and returns a value but is not inteeded to be used with signals.


  • Moderators

    Invokable methods are like slots are made available through the metatype system, so I don't think it's more "lightweight". The difference is rather a semantic one (do you want to use it for signal/slot connections? Or is it just about making a method available in QtScript?). Also, constructors can be marked as Q_INVOKABLE, while they cannot be slots.



  • Thanks kkoehne, you confirmed what I expected.



  • Can I somehow mark static methods with Q_INVOKABLE and use them in QtScript without needance to write huge binding for this method?



  • You might want create separate thread for this...


Log in to reply