QT5 信号不会激活插槽内的功能
QT5 Signals does not activate the functions inside SLOT
大家早上好,谢谢大家抽出宝贵时间。
我已经创建了一个魔方程序,我想将其与串行链路控制器连接。一切都工作正常且独立,但是当我将线程(串行连接(连接到程序的其余部分时,它不起作用。
我创建了一个调用立方体旋转函数的信号。信号被调用并且它很好地调用了函数,但它不会更改内部的值,就像创建我的类的新实例而不直接修改它一样。 代码调用得很好,但我在 qwidget 中的显示没有改变。 这是我代码的一部分,感谢您的帮助!对不起,我的英语我来自法国:)
立方体 :
class Cube : public QWidget {
Q_OBJECT
private:
int w[3][3];
int o[3][3];
int v[3][3];
int r[3][3];
int b[3][3];
int j[3][3];
int wPerma[3][3];
int oPerma[3][3];
int vPerma[3][3];
int rPerma[3][3];
int bPerma[3][3];
int jPerma[3][3];
public:
QWidget Fenetre;
QString str;
QGridLayout *gridLayout = new QGridLayout(&Fenetre);
Cube();
.......
public slots:
void rotationFComplete();
void rotationBComplete();
void rotationUComplete();
void rotationDComplete();
void rotationLComplete();
void rotationRComplete();
void rotationFpComplete();
void rotationBpComplete();
void rotationUpComplete();
void rotationDpComplete();
void rotationLpComplete();
void rotationRpComplete();
void melangeCube();
void resetCube();signals:
void MySignal( void );
};
class serial : public Cube {
public:
int Port();
};
我的信号在立方体函数中的定义:
QObject::connect(this, SIGNAL(MySignal()), this, SLOT(rotationFComplete()));
我发出信号的地方:
int serial::Port()
{
// Serial object
SerialPortManager serial;
unsigned char buffer[128]="";
int ret = 0;
bool State1 = false,
State2 = false,
State3 = false,
State4 = false,
State5 = false,
State6 = false,
State7 = false,
State8 = false,
State9 = false,
State10 = false,
State11 = false,
State12 = false,
State13 = false,
State14 = false,
State15 = false,
State16 = false;
int Octet1,Octet2;
QString temp;
emit MySignal();
......
我的主要.cpp :
int main(int argc, char *argv[]){
QApplication app(argc, argv);
serial* lecture = new serial();
Cube c;
c.affichage2d();
thread th(&serial::Port, lecture);
c.Fenetre.show();
return app.exec();
}
serial *lecture
和Cube c
是两个不同的对象。你的意思是以下吗?
QObject::connect(lecture, &Cube::MySignal, &c, &Cube::rotationFComplete);
相关文章:
- 从Q_INVOKABLE功能或插槽中更改QQuick图像源
- 升压信号2将插槽传递到成员功能以断开连接
- QT5 信号不会激活插槽内的功能
- 当再次触发信号时,从Qt插槽执行的功能被第二次调用时会发生什么?
- QT和新的信号槽语法,QApplication::退出主功能外的插槽
- C++ QT:获取指向信号的指针和插槽功能的函数
- 如何在没有对象的情况下执行插槽功能
- 如何在Qt中使用静态插槽功能
- C++/Qt项目中的连接功能中不存在插槽?(已经重新运行了制作)
- 是否可以将一个类别的插槽或常规功能从一个类连接到另一个类的插槽或常规功能?(QT)
- 提取接收功能或插槽中的菜单操作数据
- STD ::功能和信号/插槽系统
- 将变量或QString传递到插槽(function())C 中的功能
- Qt移动插槽功能到另一个cpp文件
- 如何连接到具有通用功能/插槽的boost::信号
- Qt插槽,没有用于调用的匹配功能
- QObject信号和插槽未访问功能
- Qt:如何为所有小部件和小部件类型实现通用基类信号/插槽功能(通过虚拟基类插槽)
- QT C++ - 信号和插槽:"No such slot QLabel..."甚至插槽功能也存在于我的类中
- 实现插槽功能当且仅当文本框具有焦点并按下"Enter"时?