QT5 Signals 没有激活 SLOT 里面的功能

QT5 Signals does not activate the functions inside SLOT

大家早上好,感谢您的宝贵时间。

我创建了一个魔方程序,我想将它与串行连接 link controller.Everything 工作正常且独立但是当我将我的线程(串行连接)连接到其余部分时该程序不起作用。

我创建了一个调用立方体旋转函数的信号。信号被调用,它很好地调用了函数,但它不会改变内部的值,这就像在不直接修改它的情况下创建我的 class 的新实例。 代码调用得很好,但我在 qwidget 中的显示没有改变。 这是我的代码的一部分,感谢您的帮助!对不起我的英语我来自法国:)

cube.h :

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

我的信号在Cube函数中的定义:

    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();
    ......

我的main.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 *lectureCube c 是两个不同的对象。您是指以下内容吗?

QObject::connect(lecture, &Cube::MySignal, &c, &Cube::rotationFComplete);