我在C++中使用Visual Studio 2013中的Qt。我正尝试将信号连接到插槽。问题是信号被发送,但插槽功能从未被调用,我不知道发生了什么。此代码在早期工作,但在将代码从32位的Visual Studio 2012迁移到64位的Visual Studio 2013并做了一些更改后,它不再起作用。它会打印调试语句:发送前,发送图像和连接之前,但不会打印出接收到的图像。有人可以帮忙吗?Qt信号插槽:信号已发送,但未插入插槽
Streamer.h
signals:
//Signal to output frame to be displayed
void processedImageStream(const vector<QImage> &imgs, const QImage &image2, const QImage &image3, const QImage &image4);
Streamer.cpp在run()函数
qDebug() << "before sending";
emit processedImageStream(imgs,imgIntel, imgIntelDepth, imgIntelIR);
qDebug() << "images sent!";
MainWindow.h
private slots:
//Display video frame in streamer UI
void updateStreamerUI(const vector<QImage> &imgs, const QImage &imgIntel, const QImage &imgIntelDepth, const QImage &imgIntelIR);
private:
Streamer* myStreamer;
MainWindow.cpp
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
//Streamer initialization
myStreamer = new Streamer();
QObject::connect(myStreamer, SIGNAL(processedImageStream(vector<QImage>, QImage, QImage, QImage)), this, SLOT(updateStreamerUI(vector<QImage>, QImage, QImage, QImage)));
qDebug() << "connected";
ui.setupUi(this);
}
//slot for when new images are sent from the Streamer class
void MainWindow::updateStreamerUI(const vector<QImage> &imgs, const QImage &imgIntel, const QImage &imgIntelDepth, const QImage &imgIntelIR) {
qDebug() << "images received!";
//rest of the code
}
什么是QObject的返回值::连接()? – JKSH 2014-09-10 23:23:38
返回值为true,所以必须连接 – user3838815 2014-09-10 23:26:28