Is it possible to change the name of the handler function or no?
-
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?
-
Don't use auto-connect feature - it's not safe (as you see) - connect you signals and slots with c++ code.
-
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
-
@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.
-
@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. -
mrjj,
How do you connect the button to the slot? -
@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?