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);
};
我已经看到很多关于此错误的问题,但解决方案不适用于此处。我在这里想念的是什么?
答案 0 :(得分:1)
在连接通话中,您是否正在连接ui->bigImgLabel
的广告位?可能你的意思是picLabel
;根据错误消息,ui->bigImgLabel
是一个简单的QLabel
。