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. Is it possible to change the name of the handler function or no?
Forum Updated to NodeBB v4.3 + New Features

Is it possible to change the name of the handler function or no?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 5 Posters 1.3k Views 1 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.
  • S Offline
    S Offline
    stretchthebits
    wrote on last edited by
    #1

    Hello all.
    I am a Qt newbie.
    This is about changing the name of a function.

    With VC++6 (MFC), I would go into the resource editor, add a button to the dialog box. Give a name ID to the button such as IDC_BUTTON_HELLO. I tend can add a handler function when a click occurrs on the button. The handler function might be named MyWindowsClass::OnButtonHelloClick().
    I could modify the name of the function.

    Under Qt Creator, things seem different.
    It looks like it automatically names the function to
    MyWindowsClass::on_IDC_BUTTON_HELLO_clicked()

    If I change the name of the function, the compiler does not complain. The program runs but the function does not get called.

    Is it possible to change the name of the handler function or no?

    aha_1980A 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by aha_1980
      #2

      Don't use auto-connect feature - it's not safe (as you see) - connect you signals and slots with c++ code.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      S 1 Reply Last reply
      4
      • S stretchthebits

        Hello all.
        I am a Qt newbie.
        This is about changing the name of a function.

        With VC++6 (MFC), I would go into the resource editor, add a button to the dialog box. Give a name ID to the button such as IDC_BUTTON_HELLO. I tend can add a handler function when a click occurrs on the button. The handler function might be named MyWindowsClass::OnButtonHelloClick().
        I could modify the name of the function.

        Under Qt Creator, things seem different.
        It looks like it automatically names the function to
        MyWindowsClass::on_IDC_BUTTON_HELLO_clicked()

        If I change the name of the function, the compiler does not complain. The program runs but the function does not get called.

        Is it possible to change the name of the handler function or no?

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi @stretchthebits,

        as @Christian-Ehrlicher said, you can connect the signal clicked with a slot in your program and you can name that as you like.

        See https://doc.qt.io/qt-5/signalsandslots.html

        Regards

        Qt has to stay free or it will die.

        1 Reply Last reply
        4
        • Christian EhrlicherC Christian Ehrlicher

          Don't use auto-connect feature - it's not safe (as you see) - connect you signals and slots with c++ code.

          S Offline
          S Offline
          stretchthebits
          wrote on last edited by
          #4

          @Christian-Ehrlicher
          Hello aha_1980 and Christian Ehrlicher.
          The thing is that it is handy to design the window/dialog box/form using the designer thing in Qt Creator.
          If I buttons via code, I need to use setGeometry to position the button.
          Also, I have lots of buttons, edit boxes to create. Maybe 70.

          Thanks dudes.

          mrjjM 1 Reply Last reply
          0
          • S stretchthebits

            @Christian-Ehrlicher
            Hello aha_1980 and Christian Ehrlicher.
            The thing is that it is handy to design the window/dialog box/form using the designer thing in Qt Creator.
            If I buttons via code, I need to use setGeometry to position the button.
            Also, I have lots of buttons, edit boxes to create. Maybe 70.

            Thanks dudes.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #5

            @stretchthebits
            Hi
            You can still use Designer but instead of right clicking and select Goto Slot
            you manually connect the buttons to the needed slots. (in code)

            You cannot rename the slots if you use the auto connect feature as
            it looks for a certain pattern.

            1 Reply Last reply
            4
            • S Offline
              S Offline
              stretchthebits
              wrote on last edited by
              #6

              mrjj,
              How do you connect the button to the slot?

              W 1 Reply Last reply
              0
              • S stretchthebits

                mrjj,
                How do you connect the button to the slot?

                W Offline
                W Offline
                wrosecrans
                wrote on last edited by
                #7

                @stretchthebits said in Is it possible to change the name of the handler function or no?:

                How do you connect the button to the slot?

                https://doc.qt.io/qt-5/signalsandslots.html

                1 Reply Last reply
                3

                • Login

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