Qt connect()没有QObject或插槽

Kry*_*hic 2 c++ qt

我知道我想要实现的是可能的,因为我可以用lambda表达式来完成它,之前我已经完成了它(几个月前我只是不记得语法).基本上,我想将一个函数连接到一个计时器/按钮/等.促进活动的运作.

这是我的工作代码:

connect( &renderTimer, &QTimer::timeout, [ = ]() {
        onTimerUpdate();
    } );
Run Code Online (Sandbox Code Playgroud)

这使用lambda连接到插槽.我想只引用函数本身而不是使用lambda表达式.我试过插入方法onTimerUpdate(),&onTimerUpdate但没有一个工作.我不想使用QObject它或任何预先生成的bullcrap - 我也不想在我的班级中定义插槽.我想简单地将它直接连接到我的函数.

dte*_*ech 10

这是连接到成员函数时的格式:

QObject::connect(&renderTimer, &QTimer::timeout, this, &ArclightGLWidget::onTimerUpdate); 
Run Code Online (Sandbox Code Playgroud)

这是连接到自由函数时的格式(对于lambda也是如此)

QObject::connect(&renderTimer, &QTimer::timeout, onTimerUpdate); 
Run Code Online (Sandbox Code Playgroud)

这是连接到静态成员函数时的格式:

QObject::connect(&renderTimer, &QTimer::timeout, SomeType::onTimerUpdate); 
Run Code Online (Sandbox Code Playgroud)