QTableWidget add parameters to slot
-
Hello all
I have a tablewidget and i want to add two parameters to itemClicked().
The original Slot works fine:
*.hvoid on_tbl_suche_itemClicked(QTableWidgetItem *item);
*.cpp
void MainWindow::on_tbl_suche_itemClicked(QTableWidgetItem *item){ cout << "Hello" << endl; }
But if I add parameters
*.h
void on_tbl_suche_itemClicked(QTableWidgetItem *item, Kurve kurve, Pumpe_o pumpe);
*.cpp
void MainWindow::on_tbl_suche_itemClicked(QTableWidgetItem *item, Kurve kurve, Pumpe_o pumpe){ cout << "Hello" << endl; }
I receive the error message
QMetaObject::connectSlotsByName: No matching signal for on_tbl_suche_itemClicked(QTableWidgetItem*,Kurve,Pumpe_o)
How can I make the signal/slot work with additional parameters?
Thanks in advance
Thomas -
Hello all
I have a tablewidget and i want to add two parameters to itemClicked().
The original Slot works fine:
*.hvoid on_tbl_suche_itemClicked(QTableWidgetItem *item);
*.cpp
void MainWindow::on_tbl_suche_itemClicked(QTableWidgetItem *item){ cout << "Hello" << endl; }
But if I add parameters
*.h
void on_tbl_suche_itemClicked(QTableWidgetItem *item, Kurve kurve, Pumpe_o pumpe);
*.cpp
void MainWindow::on_tbl_suche_itemClicked(QTableWidgetItem *item, Kurve kurve, Pumpe_o pumpe){ cout << "Hello" << endl; }
I receive the error message
QMetaObject::connectSlotsByName: No matching signal for on_tbl_suche_itemClicked(QTableWidgetItem*,Kurve,Pumpe_o)
How can I make the signal/slot work with additional parameters?
Thanks in advance
Thomas@Thomas-63
At present you seem to be using the "auto-connect" feature from Qt Designer of naming your sloton_tbl_suche_itemClicked
and having that auto-connect to a widget namedtbl_suche
.You won't be able to start on passing your own parameters until you write your own
connect()
statement in code which you can alter. Start by getting the normalitemClicked
signal/slot (without your own parameters) working with your own explicitconnect()
. Then come back for help on C++ lambdas, which you will need to pass your parameters. Do not use the old-styleSIGNAL
/SLOT()
macros in yourconnect()
s, read and follow the patterns in https://wiki.qt.io/New_Signal_Slot_Syntax, where it also shows lambdas for slots when you are ready. -
Wow, this seems complicated.
Maybe it is easier to retrieve the needed parameters within the standard slot...
Thank you anyway, JonB!
@Thomas-63
Sooner or later, you will need to change over to not use the auto-connect and do your ownconnect()
s anyway. And use the new style, not theSIGNAL
/SLOT()
macros. And then you will be able to use lambdas and pass your own parameters. Sooner you do so, better it will be for you :)