QT连接 - “没有这样的插槽”错误

时间:2014-03-20 14:00:14

标签: c++ qt signals-slots

QObject::connect: No such slot QLabel::mousePressEvent(QString) in ..\exportwindow.cpp:42
QObject::connect:  (receiver name: 'bigImgLabel')

我在这里尝试连接:

void ExportWindow::on_chooseFolderButton_clicked()
{
//QString fileName = QFileDialog::getExistingDirectory( this, tr("Open Image"), tr(""), 0);
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image"), "/home/jana", tr("Image Files (*.png *.jpg *.bmp)"));
QImage image(fileName);

ClickableImage* picLabel = new ClickableImage(ui->scrollArea);
picLabel->path = QString(fileName);
picLabel->setPixmap(QPixmap::fromImage(image));
ui->scrollArea->setWidget(picLabel);
connect(picLabel, SIGNAL(leftButtonPressed(QString&)),ui->bigImgLabel, SLOT(mousePressEvent(QString&)));
}

这是我创建bigPicLabel(ExportWindow的构造函数)

的地方
ClickableImage* bigPicLabel = new ClickableImage(this);
vbl->addWidget(bigPicLabel);

这是类声明

class ClickableImage:public QLabel
{
Q_OBJECT
public:
ClickableImage(QWidget *parent = 0);
QString path;
public slots:
void mousePressEvent(QString& imgPath);

signals:
void leftButtonPressed(QString& imgPath);
};

我已经看到很多关于此错误的问题,但解决方案不适用于此处。我在这里想念的是什么?

1 个答案:

答案 0 :(得分:1)

在连接通话中,您是否正在连接ui->bigImgLabel的广告位?可能你的意思是picLabel;根据错误消息,ui->bigImgLabel是一个简单的QLabel