Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Button event with QT designer
Forum Update on Monday, May 27th 2025

Button event with QT designer

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
8 Posts 3 Posters 3.0k Views
  • 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.
  • R Offline
    R Offline
    Rackelsack
    wrote on 28 Nov 2023, 16:26 last edited by
    #1

    Hello,
    I am completetly new to qt designer and qt. I was wondering if there is a way in the designer to specify whigh function a button click should call. Or do I have to add that later in the code?

    S 1 Reply Last reply 28 Nov 2023, 22:45
    0
    • R Rackelsack
      28 Nov 2023, 16:26

      Hello,
      I am completetly new to qt designer and qt. I was wondering if there is a way in the designer to specify whigh function a button click should call. Or do I have to add that later in the code?

      S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 28 Nov 2023, 22:45 last edited by
      #2

      Hi,

      You do that later in the code using the new function pointer syntax.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      R 1 Reply Last reply 29 Nov 2023, 11:52
      0
      • S SGaist
        28 Nov 2023, 22:45

        Hi,

        You do that later in the code using the new function pointer syntax.

        R Offline
        R Offline
        Rackelsack
        wrote on 29 Nov 2023, 11:52 last edited by
        #3

        @SGaist Thanks for the reply. I will have to look in how that works.

        J 1 Reply Last reply 29 Nov 2023, 12:04
        0
        • R Rackelsack
          29 Nov 2023, 11:52

          @SGaist Thanks for the reply. I will have to look in how that works.

          J Offline
          J Offline
          JonB
          wrote on 29 Nov 2023, 12:04 last edited by JonB
          #4

          @Rackelsack
          @SGaist is the expert on Qt, but I am not sure why he has answered that you have to do this in code? Qt Creator/Designer has always allowed attachment of slots to (pre-existing) signals in the design editor, e.g. View > Views > Signal and Slots Editor. This could be used for the clicked signal of a QPushButton. Unless that has changed in a recent Creator release, but I would doubt that?

          However, there are so few advantages to doing it that way and several "gotchas" that we would recommend people consider only doing signal/slot connections in code as preferable. And sooner or later using Qt you will want to know how to do connect()s explicitly in code anyway.

          R S 2 Replies Last reply 29 Nov 2023, 17:49
          0
          • J JonB
            29 Nov 2023, 12:04

            @Rackelsack
            @SGaist is the expert on Qt, but I am not sure why he has answered that you have to do this in code? Qt Creator/Designer has always allowed attachment of slots to (pre-existing) signals in the design editor, e.g. View > Views > Signal and Slots Editor. This could be used for the clicked signal of a QPushButton. Unless that has changed in a recent Creator release, but I would doubt that?

            However, there are so few advantages to doing it that way and several "gotchas" that we would recommend people consider only doing signal/slot connections in code as preferable. And sooner or later using Qt you will want to know how to do connect()s explicitly in code anyway.

            R Offline
            R Offline
            Rackelsack
            wrote on 29 Nov 2023, 17:49 last edited by
            #5

            @JonB Thanks for the info. The point is just that if I change the code and then later want to change something in the gui with the designer then the changes made will be lost. Or how does one usually handle changes made in the designer?

            J 1 Reply Last reply 29 Nov 2023, 18:01
            0
            • R Rackelsack
              29 Nov 2023, 17:49

              @JonB Thanks for the info. The point is just that if I change the code and then later want to change something in the gui with the designer then the changes made will be lost. Or how does one usually handle changes made in the designer?

              J Offline
              J Offline
              JonB
              wrote on 29 Nov 2023, 18:01 last edited by JonB
              #6

              @Rackelsack
              Nope, that is exactly one of the "gotchas", I'm afraid. Designer doesn't adjust for renaming (unless that has changed). Hence suggestion that you just use connect()s in code, it isn't that important to be able to do in Designer.

              EDIT
              Sorry, that's not the direction you are asking about. It's actually more likely to go wrong from a Designer change! You are going to have write code for everything else. If you rename or delete in Designer, you would have to adjust any code you had written (you will get compilation errors so you'll know). In principle, you will never lose anything in Designer from whatever you do in code. Designer creates a .ui file, uic gets run on it and produces code. So your code changes won't affect Designer.

              1 Reply Last reply
              0
              • J JonB
                29 Nov 2023, 12:04

                @Rackelsack
                @SGaist is the expert on Qt, but I am not sure why he has answered that you have to do this in code? Qt Creator/Designer has always allowed attachment of slots to (pre-existing) signals in the design editor, e.g. View > Views > Signal and Slots Editor. This could be used for the clicked signal of a QPushButton. Unless that has changed in a recent Creator release, but I would doubt that?

                However, there are so few advantages to doing it that way and several "gotchas" that we would recommend people consider only doing signal/slot connections in code as preferable. And sooner or later using Qt you will want to know how to do connect()s explicitly in code anyway.

                S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 29 Nov 2023, 19:39 last edited by
                #7

                @JonB said in Button event with QT designer:

                @Rackelsack
                @SGaist is the expert on Qt, but I am not sure why he has answered that you have to do this in code? Qt Creator/Designer has always allowed attachment of slots to (pre-existing) signals in the design editor, e.g. View > Views > Signal and Slots Editor. This could be used for the clicked signal of a QPushButton. Unless that has changed in a recent Creator release, but I would doubt that?

                However, there are so few advantages to doing it that way and several "gotchas" that we would recommend people consider only doing signal/slot connections in code as preferable. And sooner or later using Qt you will want to know how to do connect()s explicitly in code anyway.

                My answer might have been a bit terse here indeed but I would like to point that I didn't write that someone "has to do it by code" ;-)

                Anyway, my point was that you are better off doing it in code to get better control of what is happening. Use designer for its design capabilities and for the rest, write code.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • R Offline
                  R Offline
                  Rackelsack
                  wrote on 30 Nov 2023, 17:13 last edited by
                  #8

                  Ok thanks for all the replies. I will just code the connect(). Seems the simplest.

                  1 Reply Last reply
                  1

                  1/8

                  28 Nov 2023, 16:26

                  • Login

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