Yet another questions about "go to slot" - #1 need an example adding / using signal parameters
-
wrote on 20 Jul 2021, 00:41 last edited by
I like to further improve my "connect" skill using "go to slot ".
Have been trying to find ( asked Mrs Google ) an example of usage of "signal parameters".
No success so far.void on_<object name>_<signal name>(<signal parameters>);
Anybody can help me ?
Here is "plain" "go to slot" function created in QDesigner using "go to slot " and selecting "SIGNAL " cliick(). Connecting using GUI to "SLOT " clear() works fine , but it does not show in the "on_(object)_(signal ) function .
void TabWidget_Chat::on_pushButton_13_clicked()
{}
-
wrote on 20 Jul 2021, 01:54 last edited by stretchthebits
You want to know what the function should look like for a button that gets pushed?
Your on_pushButton_13_clicked() looks fine,
In your TabWidget_Chat class, put
private slots:
void on_pushButton_13_clicked();and in your TabWidget_Chat constructor, allocate your button and then call:
connect(THEBUTTON, &QAbstractButton::clicked, this, &TabWidget_Chat::on_pushButton_13_clicked, Qt::AutoConnection); -
I like to further improve my "connect" skill using "go to slot ".
Have been trying to find ( asked Mrs Google ) an example of usage of "signal parameters".
No success so far.void on_<object name>_<signal name>(<signal parameters>);
Anybody can help me ?
Here is "plain" "go to slot" function created in QDesigner using "go to slot " and selecting "SIGNAL " cliick(). Connecting using GUI to "SLOT " clear() works fine , but it does not show in the "on_(object)_(signal ) function .
void TabWidget_Chat::on_pushButton_13_clicked()
{}
@AnneRanch said in Yet another questions about "go to slot" - #1 need an example adding / using signal parameters:
I like to further improve my "connect" skill using "go to slot ".
let me stop you right here.
If you wan't to improve your "connect" skill than never ever use the connect by name feature -aka go to slot, when using Designer plugin.
These types of connections are very brittle, as a simple object rename would break your code -
wrote on 21 Jul 2021, 18:10 last edited by
BUMP
... an example of usage of "signal parameters".
while using "go to slot :void on_<object name>_<signal name>(<signal parameters>);
Anybody can help me ?
-
BUMP
... an example of usage of "signal parameters".
while using "go to slot :void on_<object name>_<signal name>(<signal parameters>);
Anybody can help me ?
-
I like to further improve my "connect" skill using "go to slot ".
Have been trying to find ( asked Mrs Google ) an example of usage of "signal parameters".
No success so far.void on_<object name>_<signal name>(<signal parameters>);
Anybody can help me ?
Here is "plain" "go to slot" function created in QDesigner using "go to slot " and selecting "SIGNAL " cliick(). Connecting using GUI to "SLOT " clear() works fine , but it does not show in the "on_(object)_(signal ) function .
void TabWidget_Chat::on_pushButton_13_clicked()
{}
wrote on 22 Jul 2021, 07:29 last edited by@AnneRanch
Hi
More in general.
In ui you usually have controls that derive from QWidget then QObject.in .h of your UI
protected slots:
void MyRadioButton(bool)in .cpp of your UI
So you can connect function to connect a signal of QWidget to your slot. so where you initialize your UI you can write
connect( ui->MyRadioButton, &QRadioButton::toggled, this, &MyUiObject::MyRadioButton );void MyUiObject::MyRadioButton( bool value )
{
...
}Using "go to slot" is easy and fast but you could have a problem if you change the name of a control, you can compile the project but your old slot is no longer connect.
-
BUMP
... an example of usage of "signal parameters".
while using "go to slot :void on_<object name>_<signal name>(<signal parameters>);
Anybody can help me ?
@AnneRanch said in Yet another questions about "go to slot" - #1 need an example adding / using signal parameters:
BUMP
... an example of usage of "signal parameters".
while using "go to slot :void on_<object name>_<signal name>(<signal parameters>);
Anybody can help me ?
void on_pushButton_13_toggled(bool checked); void on_pushButton_13_clicked(bool checked);
-
I like to further improve my "connect" skill using "go to slot ".
Have been trying to find ( asked Mrs Google ) an example of usage of "signal parameters".
No success so far.void on_<object name>_<signal name>(<signal parameters>);
Anybody can help me ?
Here is "plain" "go to slot" function created in QDesigner using "go to slot " and selecting "SIGNAL " cliick(). Connecting using GUI to "SLOT " clear() works fine , but it does not show in the "on_(object)_(signal ) function .
void TabWidget_Chat::on_pushButton_13_clicked()
{}
wrote on 22 Jul 2021, 08:05 last edited by@AnneRanch
Only another note
When you manually connect a control's signal to your slot don't use the same name of "go to slot" because else your slot will be called twice, once for "go to slot" mechanism and once for your connect.e.g.
if you have a push button called on_pushButton_13 you musn't call your slot void on_pushButton_13_clicked(bool checked); if you use the connect function to manage clicked signal.I hope I'm clear, no for you but for my english :(
1/8