Qt Signal 和 Slot 连接似乎不起作用
我已经检查了很多次,但找不到我的错误。
在我的主类中,我有:
connect(userControl, SIGNAL(DataToPlot(std::vector<double>)), this, SLOT(test(std::vector<double>)));
在同一个类中,我有一个测试函数和原型:
public slots:
void test(std::vector<double>);
void RelayduinoGuiThreading::test(std::vector<double> x)
{
123; // I put a breakpoint on this line to check when the slot is called.
}
在单独的线程中运行,我有以下内容:
signals:
void DataToPlot(std::vector<double>);
somefunction
{
// Stuff...
std::vector<double> x;
emit(DataToPlot(x));
}
现在,如果我将 std::vector 更改为 int 或 a双倍,它有效。
另外,#include 位于两个类头中。
我什至在我的项目中的其他地方发出 std::vector 并捕获信号并且没有任何问题。
非常感谢您的帮助。
谢谢。
I've checked this a heap of times and cannot find my error.
In my main class, I have:
connect(userControl, SIGNAL(DataToPlot(std::vector<double>)), this, SLOT(test(std::vector<double>)));
In the same class I have a test function and prototype:
public slots:
void test(std::vector<double>);
void RelayduinoGuiThreading::test(std::vector<double> x)
{
123; // I put a breakpoint on this line to check when the slot is called.
}
Running in a seperate thread, I have the following:
signals:
void DataToPlot(std::vector<double>);
somefunction
{
// Stuff...
std::vector<double> x;
emit(DataToPlot(x));
}
Now here's the thing, if I change the std::vector to an int, or a double, it works.
Also, #include is in both class headers.
I even have somewhere else in my project where I emit an std::vector and catch the signal and have no problems with that.
Help is much appreciated.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 Qt Docu 中提到的
因此,在您的主应用程序中,您必须调用:
并在您的
RelayduinoGuiThreading
头文件中(如 tibur 提到的):这里是详细的文档
As it is mentioned in Qt Docu
So in your main application you have to call:
and in your
RelayduinoGuiThreading
header file (as tibur mentioned):Here is the documentation in detail
尝试将其添加到您的
RelayduinoGuiThreading
标头中:Try to add this in your
RelayduinoGuiThreading
header: