Solved QObject::connect: No such slot (for QComboBox object)
-
Hi...
I have a window which has a QComboBox component, on constructor I add some QStrings so this will be composed by some names., then final user selects one.I'm looking for a way the user select and call a function, so i need to use slot and signals..:
//mywindow.h class mywindow{ Q_OBJECT private slots: void onAct_cBox(int _i); }
//mywindow.cpp //Constructor: connect(ui->cBox, SIGNAL(activated(int)), this, SLOT(onAct_cBox())); //member: void mywindow::onAct_cBox(int _i){ qDebug() << "Im here"; //never reached here }
After building:
QObject::connect: No such slot mywindow::onAct_cBox() in
../reservas_minsal/mywindow.cpp:19
QObject::connect: (sender name: 'cBox')
QObject::connect: (receiver name: 'mywindow')Any clues?
Thanks so much. -
void mywindow::onAct_cBox(int _i){ qDebug() << "Im here"; //never reached here }
Takes and int
you have none in
connect(ui->cBox, SIGNAL(activated(int)), this, SLOT(onAct_cBox()));
-
Thanks for your answer...
connect(ui->cBox, SIGNAL(activated(int)), this, SLOT(onAct_cBox(int)));
I tried that too, may i still misunderstood it?
-
That should work.
Do you still get any error message? -
@U7Development change
onAct_cBox
toonActivatedcBox
, See https://doc.qt.io/qt-5/qmetaobject.html#connectSlotsByName. The MOC uses some rules like the formaton_<object name>_<signal name>(<signal parameters>);
to make connections, and which in your case does not match so it throws that warning. -
@JSher << @Bonnie << @eyllanesc << " I'm pretty sure i'd try adding int on the lambda argument, now is working";
Thanks!