Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. "go to slot" vs coded signal/slot connection
Forum Updated to NodeBB v4.3 + New Features

"go to slot" vs coded signal/slot connection

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 5 Posters 3.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MortyMarsM Offline
    MortyMarsM Offline
    MortyMars
    wrote on last edited by
    #1

    Hello everyone,
    Understanding that the message "Slots named on_foo_bar are error prone" warns me of potential future link errors, I've tried to make the link in question hard in the code using the 'connect' command:

    Capture d’écran 2024-04-14 à 01.08.54.jpg

    However, I still get the same warning "Slots named...", so I don't understand what I've gained by adding this code (as long as it's correct)

    Thank you for your feedback

    Pl45m4P 1 Reply Last reply
    0
    • MortyMarsM MortyMars

      Hello everyone,
      Understanding that the message "Slots named on_foo_bar are error prone" warns me of potential future link errors, I've tried to make the link in question hard in the code using the 'connect' command:

      Capture d’écran 2024-04-14 à 01.08.54.jpg

      However, I still get the same warning "Slots named...", so I don't understand what I've gained by adding this code (as long as it's correct)

      Thank you for your feedback

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @MortyMars said in "go to slot" vs coded signal/slot connection:

      However, I still get the same warning "Slots named...", so I don't understand what I've gained by adding this code (as long as it's correct)

      Because the on_<objectname>_<signal> syntax, as used by Qt's auto-connect, can be broken very easily.

      Here is a similar topic, where this "go-to-slot"-connection way was discussed with a user.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      MortyMarsM 1 Reply Last reply
      3
      • Pl45m4P Pl45m4

        @MortyMars said in "go to slot" vs coded signal/slot connection:

        However, I still get the same warning "Slots named...", so I don't understand what I've gained by adding this code (as long as it's correct)

        Because the on_<objectname>_<signal> syntax, as used by Qt's auto-connect, can be broken very easily.

        Here is a similar topic, where this "go-to-slot"-connection way was discussed with a user.

        MortyMarsM Offline
        MortyMarsM Offline
        MortyMars
        wrote on last edited by
        #3

        Hi @Pl45m4

        Thank you for your reply and the link, which will help me to understand this signal-slot process better.

        With this connection through the code, I'll be able to rename my objects while preserving their bindings, for example, isn't that right?

        Regarding the warning message, I've managed to remove it by moving the definition of the method concerned from the "private slots:" section to "private:"...

        JonBJ 1 Reply Last reply
        0
        • MortyMarsM MortyMars

          Hi @Pl45m4

          Thank you for your reply and the link, which will help me to understand this signal-slot process better.

          With this connection through the code, I'll be able to rename my objects while preserving their bindings, for example, isn't that right?

          Regarding the warning message, I've managed to remove it by moving the definition of the method concerned from the "private slots:" section to "private:"...

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @MortyMars said in "go to slot" vs coded signal/slot connection:

          With this connection through the code, I'll be able to rename my objects while preserving their bindings, for example, isn't that right?

          You probably can, but honestly if you use Qt a bit most people just don't bother with the hassle. Connecting from Designer is not worth that much, we all use our own explicit connect() statements instead, and do not use connect slots by name. Up to you.

          Regarding the warning message, I've managed to remove it by moving the definition of the method concerned from the "private slots:" section to "private:"...

          IIRC, slots is #defined to nothing/empty. So private slots: is already just private. Hence I don't know what you did or think you achieved. Maybe it's just some moc message. There you are.

          MortyMarsM 1 Reply Last reply
          1
          • JonBJ JonB

            @MortyMars said in "go to slot" vs coded signal/slot connection:

            With this connection through the code, I'll be able to rename my objects while preserving their bindings, for example, isn't that right?

            You probably can, but honestly if you use Qt a bit most people just don't bother with the hassle. Connecting from Designer is not worth that much, we all use our own explicit connect() statements instead, and do not use connect slots by name. Up to you.

            Regarding the warning message, I've managed to remove it by moving the definition of the method concerned from the "private slots:" section to "private:"...

            IIRC, slots is #defined to nothing/empty. So private slots: is already just private. Hence I don't know what you did or think you achieved. Maybe it's just some moc message. There you are.

            MortyMarsM Offline
            MortyMarsM Offline
            MortyMars
            wrote on last edited by
            #5

            @JonB
            What I just wanted to make clear is that moving the method definition (after creating the connection with 'connect') made the warning disappear :
            Capture d’écran 2024-04-14 à 21.01.01.jpg

            JonBJ 1 Reply Last reply
            0
            • MortyMarsM MortyMars

              @JonB
              What I just wanted to make clear is that moving the method definition (after creating the connection with 'connect') made the warning disappear :
              Capture d’écran 2024-04-14 à 21.01.01.jpg

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @MortyMars
              Well it seems to me that's just because now you are not telling it that it's a slot at all it doesn't warn you about the way it's named on_.... being "error prone". It's not an error, it's a diagnostic warning from clazy. If you don't have the connectSlotsByName() call (in setupUi(), I think, and I believe it can be turned off, which most of us do, or even if that's not possible we just don't name slots that on_... way, which Designer does, so it doesn't arise). I would rather have them marked as slots if they are slots, but not use the auto-connect-by-name. But it's up to you.

              What you should not do is on the one hand have the slots created/named and use the auto-connection and then also put in your own explicit connect() statements. That will lead to duplicate connections. Most of us long-termers use *jusT8 explicit connect()s, like the one you show.

              BTW, have a look at the thread from one of our experts going on in https://forum.qt.io/topic/156017/slot-naming-convention. Note that whichever naming convention people are picking there it is not the special on_.... for the automatic connect slots.

              MortyMarsM 1 Reply Last reply
              0
              • JonBJ JonB

                @MortyMars
                Well it seems to me that's just because now you are not telling it that it's a slot at all it doesn't warn you about the way it's named on_.... being "error prone". It's not an error, it's a diagnostic warning from clazy. If you don't have the connectSlotsByName() call (in setupUi(), I think, and I believe it can be turned off, which most of us do, or even if that's not possible we just don't name slots that on_... way, which Designer does, so it doesn't arise). I would rather have them marked as slots if they are slots, but not use the auto-connect-by-name. But it's up to you.

                What you should not do is on the one hand have the slots created/named and use the auto-connection and then also put in your own explicit connect() statements. That will lead to duplicate connections. Most of us long-termers use *jusT8 explicit connect()s, like the one you show.

                BTW, have a look at the thread from one of our experts going on in https://forum.qt.io/topic/156017/slot-naming-convention. Note that whichever naming convention people are picking there it is not the special on_.... for the automatic connect slots.

                MortyMarsM Offline
                MortyMarsM Offline
                MortyMars
                wrote on last edited by
                #7

                @JonB
                I have to admit that it's all getting a bit confusing and that I'm going to have to dig a bit deeper before I really understand why it's all happening...

                J.HilkJ 1 Reply Last reply
                0
                • MortyMarsM MortyMars

                  @JonB
                  I have to admit that it's all getting a bit confusing and that I'm going to have to dig a bit deeper before I really understand why it's all happening...

                  J.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on last edited by
                  #8

                  @MortyMars simple: don't use underscore in your function name, and you're 100% fine


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  MortyMarsM 1 Reply Last reply
                  1
                  • J.HilkJ J.Hilk

                    @MortyMars simple: don't use underscore in your function name, and you're 100% fine

                    MortyMarsM Offline
                    MortyMarsM Offline
                    MortyMars
                    wrote on last edited by
                    #9

                    Hi @J-Hilk
                    Thank you for this valuable advice, which I'll be sure to follow ;-)

                    JonBJ 1 Reply Last reply
                    1
                    • MortyMarsM MortyMars

                      Hi @J-Hilk
                      Thank you for this valuable advice, which I'll be sure to follow ;-)

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #10

                      @MortyMars
                      That's why I tried to explain earlier:

                      we just don't name slots that on_... way, which Designer does, so it doesn't arise

                      whichever naming convention people are picking there it is not the special on_.... for the automatic connect slots

                      :)

                      MortyMarsM 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @MortyMars
                        That's why I tried to explain earlier:

                        we just don't name slots that on_... way, which Designer does, so it doesn't arise

                        whichever naming convention people are picking there it is not the special on_.... for the automatic connect slots

                        :)

                        MortyMarsM Offline
                        MortyMarsM Offline
                        MortyMars
                        wrote on last edited by
                        #11

                        Hi @JonB,

                        Yes, that's what I noticed and the fact that it was repeated to me should make me remember it ;-)
                        Thanks again!

                        A 1 Reply Last reply
                        1
                        • MortyMarsM MortyMars

                          Hi @JonB,

                          Yes, that's what I noticed and the fact that it was repeated to me should make me remember it ;-)
                          Thanks again!

                          A Offline
                          A Offline
                          Anonymous_Banned275
                          wrote on last edited by Anonymous_Banned275
                          #12

                          It is not my habit to participate in opinions discussion,
                          maily because it gets (often) sidetracked into criticism of expressions instead of staying on the subject.

                          With that - Qt Inc. published numerous examples.
                          One of the "features of C++ , when originally introduced was " code reuse ...".
                          So - why reinvent the wheel when there is a suitable Qt example to "cut and paste" ?

                          Doing that - one gets "stuck "
                          with using "go to slot" or "old way " to "connect" ...

                          The bottom line - it is (personal) choice what to use,
                          BUT,
                          I just do not get the opinions that "it is unreliable , hence it should not be used "
                          END OF RANT

                          Pl45m4P 1 Reply Last reply
                          0
                          • A Anonymous_Banned275

                            It is not my habit to participate in opinions discussion,
                            maily because it gets (often) sidetracked into criticism of expressions instead of staying on the subject.

                            With that - Qt Inc. published numerous examples.
                            One of the "features of C++ , when originally introduced was " code reuse ...".
                            So - why reinvent the wheel when there is a suitable Qt example to "cut and paste" ?

                            Doing that - one gets "stuck "
                            with using "go to slot" or "old way " to "connect" ...

                            The bottom line - it is (personal) choice what to use,
                            BUT,
                            I just do not get the opinions that "it is unreliable , hence it should not be used "
                            END OF RANT

                            Pl45m4P Offline
                            Pl45m4P Offline
                            Pl45m4
                            wrote on last edited by Pl45m4
                            #13

                            @AnneRanch said in "go to slot" vs coded signal/slot connection:

                            One of the "features of C++, when originally introduced was " reuse ...".
                            So - why reinvent thre wheel when there is a sitablke Qt example?
                            The one gets "stuck "
                            with usign "go to slot" or "old way " to "connect" ...

                            You got yourself into this situation. Nobody forced you to use this whole "QtDesigner"-"GoToSlot"-thing. Because I doubt that anybody uses all these QtDesigner functions and utilities in a serious matter.
                            These are "difficulties" you wouldn't have, when having proper C++ knowledge.

                            It may seem easy and tempting to put together a GUI in QtDesigner "quick and dirty"... but especially if you want to be able to scrutinize everything and dig down to the roots, as you do (valid, not blaming you on that)... just knowing (or forcing to use) the "GoToSlot" function is.... surprise... not enough.

                            Qt is a C++ framework after all. And that's not something you can use and control by clicking with your mouse on pretty, shiny WYSIWYG editor windows.
                            (QtDesigner is actually more WYSIWYG-"lite")


                            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                            ~E. W. Dijkstra

                            A 1 Reply Last reply
                            0
                            • Pl45m4P Pl45m4

                              @AnneRanch said in "go to slot" vs coded signal/slot connection:

                              One of the "features of C++, when originally introduced was " reuse ...".
                              So - why reinvent thre wheel when there is a sitablke Qt example?
                              The one gets "stuck "
                              with usign "go to slot" or "old way " to "connect" ...

                              You got yourself into this situation. Nobody forced you to use this whole "QtDesigner"-"GoToSlot"-thing. Because I doubt that anybody uses all these QtDesigner functions and utilities in a serious matter.
                              These are "difficulties" you wouldn't have, when having proper C++ knowledge.

                              It may seem easy and tempting to put together a GUI in QtDesigner "quick and dirty"... but especially if you want to be able to scrutinize everything and dig down to the roots, as you do (valid, not blaming you on that)... just knowing (or forcing to use) the "GoToSlot" function is.... surprise... not enough.

                              Qt is a C++ framework after all. And that's not something you can use and control by clicking with your mouse on pretty, shiny WYSIWYG editor windows.
                              (QtDesigner is actually more WYSIWYG-"lite")

                              A Offline
                              A Offline
                              Anonymous_Banned275
                              wrote on last edited by
                              #14

                              @Pl45m4 I am tempted to report your post to somebody who cares.
                              THIS CONSTANT BASHING GOT TO STOP.

                              It is against my nature to discuss such behaviour,
                              however, I am going to reply in same style.

                              ( I do not care TO GET BANNED FROM ThIS CESS POOl
                              I haVE HAD IT )

                              Would you PLEASE go back to kindergarten school and learn how NOT TO PUT PEOPLE DOWN ?

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved