简体   繁体   中英

QT connect - “No such slot” error

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

Here I'm trying to connect:

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&)));
}

this is where i create bigPicLabel (constructor of ExportWindow)

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

and this is class declaration

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

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

I've seen many questions with this error, but solutions don't fit here. What did I miss here?

In the connect call, you are connecting to a slot of ui->bigImgLabel ? Probably you meant picLabel ; according to the error message, ui->bigImgLabel is a simple QLabel .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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