关于SIGNAL / SLOT qt4的问题

时间:2014-09-03 09:56:04

标签: c++ qt4

我创建了一个GUI,其中涉及从一个ComboBox( evaluation_box )中选择主题,从而将与该特定主题相关的所有主题加载到另一个ComboBox( sequence_combo_box

用于SIGNAL / SLOT的代码如下

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

但是,在这样做时,我收到以下错误消息:

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

头文件包含以下内容:

#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(char *folder,char *sequence,struct dirent *select);
                                          .
                                          .
                                          .
       protected:    
         Ui::GetSequenceFeederWidget ui_;

     };
    }

.cpp如下:

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)
{
                                     .
                                     .
                                     .
}

我在头文件中声明了readSequenceFile(char *folder,char *sequence,struct dirent *select);函数protected slots:我也尝试将其声明为public slot:,但没有用。我不明白我做错了什么。

1 个答案:

答案 0 :(得分:0)

根据您的错误消息,您的ui_.sequence_combo_boxQComboBox,显然QComboBox没有名为readSequenceFile的广告位功能。
ui_.sequence_combo_box应该是一个继承QComboBox

的类