Issues with signal and slot- Qt4



  • I have created a GUI which involves selection of topics from one ComboBox (evaluation_box) leading to load all the topics related to that particular topic into another ComboBox (sequence_combo_box).

    The code used for SIGNAL/SLOT is as follows:

    @ connect(ui_.evaluation_box, SIGNAL(currentIndexChanged(QString)), ui_.sequence_combo_box, SLOT(readSequenceFile(char *,char *,struct dirent *)));
    @

    The header file includes the following:

    @#ifndef rqt_get_sequence_feeder__GetSequenceFeeder_H
    #define rqt_get_sequence_feeder__GetSequenceFeeder_H

    #include <rqt_gui_cpp/plugin.h>

    #include <ui_get_sequence_feeder.h>
    #include <dirent.h>
    #include <image_transport/image_transport.h>
    #include <sensor_msgs/Image.h>
    #include <opencv2/core/core.hpp>
    #include <QImage>
    #include <QList>
    #include <QMutex>
    #include <QString>
    #include <QSize>
    #include <QWidget>
    #include <vector>

    namespace rqt_get_sequence_feeder {
    
    class GetSequenceFeeder
      : public rqt_gui_cpp::Plugin
     {
    
      Q_OBJECT
        public:
           GetSequenceFeeder();
    
        protected slots:            
          virtual void onFrameChanged(int);
          virtual void readSequenceFile&#40;char *folder,char *sequence,struct dirent *select&#41;;
                                          .
                                          .
                                          .
       protected:    
         Ui::GetSequenceFeederWidget ui_;
    
     };
    }@
    

    And the .cpp is as follows:

    @using namespace std;
    namespace rqt_get_sequence_feeder {

    GetSequenceFeeder::GetSequenceFeeder()
    : rqt_gui_cpp::Plugin()
    , widget_(0)
    {
    setObjectName("GetSequenceFeeder");
    }

    void GetSequenceFeeder::initPlugin(qt_gui_cpp::PluginContext& context)
    {
    connect(ui_.evaluation_box, SIGNAL(currentIndexChanged(QString)),ui_.sequence_combo_box, SLOT(readSequenceFile(char *,char *,struct dirent *)));
    .
    .
    .
    }

    void GetSequenceFeeder::readSequenceFile(char *folder ,char *sequenceFile,struct dirent *select)
    {
    .
    .
    .
    }@

    But, on doing so I get the following error message:

    @Object::connect: No such slot QComboBox::readSequenceFile(char *,char *,struct dirent *)
    Object::connect: (sender name: 'evaluation_box')
    Object::connect: (receiver name: 'sequence_combo_box')@

    I have the function readSequenceFile(char *folder,char *sequence,struct dirent *select); declared in the header file as protected slots: I also tried declaring it as public slot:, did not work. I don't understand what am I doing wrong.



  • There are a number of issues here, but to address your "No such slot" problem, it seems to me as if you are attempting to connect your SIGNAL to a QComboBox (ui_.sequence_combo_box)...and QComboBox does not have a SLOT called readSequenceFile(...)

    To connect to your sequence feeder object's readSequenceFile(...) slot, you should probably connect to "this".

    @connect(ui_.evaluation_box, SIGNAL(currentIndexChanged(QString)), this, SLOT(readSequenceFile(char *,char *,struct dirent *))); @

    Having said that, you will now run into additional issues since your signatures don't match. I suggest you read the docs a little bit more :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.