Qt World Summit: Submit your Presentation

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..:

    class mywindow{
    private slots:
         void onAct_cBox(int _i);
    connect(ui->cBox, SIGNAL(activated(int)), this, SLOT(onAct_cBox()));
    void mywindow::onAct_cBox(int _i){
        qDebug() << "Im here"; //never reached here

    After building:
    QObject::connect: No such slot mywindow::onAct_cBox() in
    QObject::connect: (sender name: 'cBox')
    QObject::connect: (receiver name: 'mywindow')

    Any clues?
    Thanks so much.

  • @U7Development

    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()));

  • @JSher

    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 to onActivatedcBox, See https://doc.qt.io/qt-5/qmetaobject.html#connectSlotsByName. The MOC uses some rules like the format on_<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";


Log in to reply