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

Is declaring functions as slot still needed/meaningful with the new function reference connect?



  • Hi all :-)

    I've been using the (meanwhile not-so anymore) new connect() using function references instead of the old SIGNAL() and SLOT() macros for some time now.

    Using this, it's (as we know) possible to connect to functions that weren't declared as slots. Thus, I wonder if it's still needed/meaningful to declare functions I intend to connect to as slots, as they could as well simply be "normal" functions.

    Is this still meaningful/good practice? And if so: why? Or is this only needed if one wans to still support the old connect() approach?

    Thanks to the Qt pros to clarify this to a Qt apprentice ;-)

    Cheers, Tobias


  • Lifetime Qt Champion

    Hi
    Marking them as slots are still meaningful with new syntax as to make it
    clear what functions the class offers to be used as slots.



  • So, altogether, it's the same when I e. g. write

    public: // Functions
        void someFunction();
    
    public: // Slots
        void someSlot();
    

    And it's not needed anymore but to be clear about the purpose of the respective functions?



  • @l3u_
    Yes, and as per what @mrjj said. See the recent discussion in https://forum.qt.io/topic/101528/can-a-signal-call-a-non-slot-method for full detail and a similar conclusion.



  • Thanks for the info!


Log in to reply