Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QObject::connect: No such slot (for QComboBox object)
Forum Updated to NodeBB v4.3 + New Features

QObject::connect: No such slot (for QComboBox object)

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 510 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    U7Development
    wrote on last edited by U7Development
    #1

    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.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JSher
      wrote on last edited by
      #2

      @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()));
      
      U 1 Reply Last reply
      1
      • J JSher

        @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()));
        
        U Offline
        U Offline
        U7Development
        wrote on last edited by
        #3

        @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?

        1 Reply Last reply
        0
        • B Offline
          B Offline
          Bonnie
          wrote on last edited by
          #4

          That should work.
          Do you still get any error message?

          1 Reply Last reply
          1
          • eyllanescE Offline
            eyllanescE Offline
            eyllanesc
            wrote on last edited by eyllanesc
            #5

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

            If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

            1 Reply Last reply
            1
            • U Offline
              U Offline
              U7Development
              wrote on last edited by
              #6

              @JSher << @Bonnie << @eyllanesc << " I'm pretty sure i'd try adding int on the lambda argument, now is working";

              Thanks!

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved