create control event function
-
wrote on 14 Jun 2018, 06:21 last edited by
Hi,
as qt (designer) beginner i wonder how to create e.g. a pushButtons OnClick Event and code it (c++)
i am using Visual Studio 2016 and the Qt designer 5.11.0.
a youtube tutorial describes: right click on the control -> "goto slot" ->.... ends with a ...::on_pushButton_clicked() function.
thats what i have expexted.But there is no "goto slot" action in the controls context menu!
How do i do that!
-
Hi,
as qt (designer) beginner i wonder how to create e.g. a pushButtons OnClick Event and code it (c++)
i am using Visual Studio 2016 and the Qt designer 5.11.0.
a youtube tutorial describes: right click on the control -> "goto slot" ->.... ends with a ...::on_pushButton_clicked() function.
thats what i have expexted.But there is no "goto slot" action in the controls context menu!
How do i do that!
@hawiwo I guess you mean OnClick slot, not event?
This is simple: right click on the push button, then you will see "Go to slot..." in the context menu. -
Hi,
as qt (designer) beginner i wonder how to create e.g. a pushButtons OnClick Event and code it (c++)
i am using Visual Studio 2016 and the Qt designer 5.11.0.
a youtube tutorial describes: right click on the control -> "goto slot" ->.... ends with a ...::on_pushButton_clicked() function.
thats what i have expexted.But there is no "goto slot" action in the controls context menu!
How do i do that!
wrote on 14 Jun 2018, 07:27 last edited by VRoninIt's is usually safer to do the connection manually in the constructor, connecting by name backfires too often.
Under
private slots:
addvoid onButtonClicked();
(you can give it whatever name you like) then in the constructor, aftersetupUi()
addconnect(ui->pushButton,&QPushButton::clicked,this,&MyClass::onButtonClicked);
(of courseMyClass
is the name of the class you are editing
P.S.
@hawiwo said in create control event function:i am using Visual Studio 2016
-
wrote on 14 Jun 2018, 08:52 last edited by
ok works.
Thanks!
1/4