简体   繁体   English

有关SIGNAL / SLOT qt4的问题

[英]Issues regarding SIGNAL/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 ). 我创建了一个GUI,该GUI涉及从一个ComboBox( Evaluation_box )中选择主题,从而将与该特定主题相关的所有主题加载到另一个ComboBox( sequence_combo_box )中。

The code used for SIGNAL/SLOT is as follows 用于SIGNAL / SLOT的代码如下

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

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')

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

     };
    }

And the .cpp is as follows: .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)
{
                                     .
                                     .
                                     .
}

I have the function readSequenceFile(char *folder,char *sequence,struct dirent *select); 我有功能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. 在标头文件中声明为protected slots:我还尝试了将其声明为public slot: ,但无效。 I dont understand what am I doing wrong. 我不明白我在做什么错。

According to your error message , your ui_.sequence_combo_box is a QComboBox , and obviously a QComboBox doesn't have a slot function named readSequenceFile . 根据您的错误消息,您的ui_.sequence_combo_box是一个QComboBox ,并且显然QComboBox没有名为readSequenceFile的插槽函数。
ui_.sequence_combo_box should be a class inherit QComboBox ui_.sequence_combo_box应该是继承QComboBox的类

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM