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
QtWS25 Last Chance

Button event with QT designer

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
8 Posts 3 Posters 2.8k 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 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?

    SGaistS 1 Reply Last reply
    0
    • R Rackelsack

      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?

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on 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
      0
      • SGaistS SGaist

        Hi,

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

        R Offline
        R Offline
        Rackelsack
        wrote on last edited by
        #3

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

        JonBJ 1 Reply Last reply
        0
        • R Rackelsack

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

          JonBJ Online
          JonBJ Online
          JonB
          wrote on 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 SGaistS 2 Replies Last reply
          0
          • JonBJ JonB

            @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 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?

            JonBJ 1 Reply Last reply
            0
            • R Rackelsack

              @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?

              JonBJ Online
              JonBJ Online
              JonB
              wrote on 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
              • JonBJ JonB

                @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.

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on 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 last edited by
                  #8

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

                  1 Reply Last reply
                  1

                  • Login

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