退出前重新进入函数

re-enter function before exiting from it

我有一个函数 test() 可以发出信号 sig()

class Game:
{
public: 
   Game();
   void test() 
       {.... 
        emit sig();
        connect(this,SIGNAL(sig()),this,SLOT(test()));
       };

signals:
    void sig();
}

我知道此代码不起作用并且程序崩溃,因为 connect 在退出之前重新进入 test()

test() 发出我想退出 test() 并重新启动它的信号时,这可能吗?

使用connect(this,SIGNAL(sig()),this,SLOT(test()), Qt::QueuedConnection);。该信号将使用线程的事件队列安排调用。