how to create slot for dynamically allocated button?
-
in my app, I should add Qpushbutton to my group box dynamically. now I want to set slot for these buttons. how can I do that??( when the button is clicked a new Qdialog must be shown).
Thank you very much
-
in my app, I should add Qpushbutton to my group box dynamically. now I want to set slot for these buttons. how can I do that??( when the button is clicked a new Qdialog must be shown).
Thank you very much
Note your post is in the forum lounge. Typically there are questions and discussions addressed which are not taken very serious. If you misplaced this thread, please let us know and a moderator can moved it for you.
Typically you have a plain QPushButton or you have created your own inheritating from QPushButton. There you have already your slots implemented. When you dynamically create a new object of those push buttons, you simply have to connect as you do with any push button.
-
in my app, I should add Qpushbutton to my group box dynamically. now I want to set slot for these buttons. how can I do that??( when the button is clicked a new Qdialog must be shown).
Thank you very much
@fatemehkarimi Hi, friend, welcome. look here.
You can watch QObject::connect
/**....some code here...*/ QPushButton* btn = new QPushButton(parent); connect(btn,&QPushButton::clicked,this,&Class::Function); /**....some code here...*/
-
@fatemehkarimi Hi, friend, welcome. look here.
You can watch QObject::connect
/**....some code here...*/ QPushButton* btn = new QPushButton(parent); connect(btn,&QPushButton::clicked,this,&Class::Function); /**....some code here...*/
@joeQ thank you very much!! it worked!!! :)))