QObject::使用update()函数连接计时器
QObject::connect timer with update() function
如何使用QObject::connect
将void update(*p_1, *p_2, *p_3, *p_4, *scene)
函数与timer()
连接?
我想要完成的是更新已传递指针的对象,并调用*scene->update()
来刷新屏幕内容。
我有一个更新功能,如下所示:
void update(*p_1, *p_2, *p_3, *p_4, *scene){
// update functions
scene->update();
}
总的来说,我得到了:
int main(int argc, char **argv){
// creating objects and calculations
view.show();
QTimer timer;
QObject::connect(&timer, SIGNAL(timeout()), update(&o_1, ..., &scene));
timer.start(1000);
return a.exec();
}
信号和函数的特征不兼容。因为如果那样,根据文档,您无法直接连接它们。
无论如何,您可以使用lambda来解决它:
QObject::connect(&timer, SIGNAL(timeout()), [&](){ update(&o_1, ..., &scene); });
相关文章:
- 是否有 Windows 用户空间函数来枚举连接的网络共享?
- 如何使用connect将qml按钮与同一类的cpp函数连接起来
- 您将如何连接"on the fly"文本+整数并将其传递给函数?
- 某些 boost::asio 异步函数是否将处理程序连接到操作,以便处理程序被触发一次?
- QObject::连接不起作用 - 使用函数语法找不到信号
- 在函数中连接两个字符,并在 C++ 中返回输出
- 用于连接向量的 Constexpr 函数
- deleteNode函数出现以中断连接列表
- QT - 连接 Qml 按钮 单击到 Cpp 构造函数
- Wt 连接函数,将参数传递给作为连接函数参数的函数
- Qt的新信号/时隙语法问题 - 连接到一个简单的函数
- C++ 将不同的类型连接成函数的字符串
- 如何编写模板函数来添加整数但连接字符串和字符类型?
- 在 for 循环中使用 lambda 函数连接信号插槽
- QObject::使用update()函数连接计时器
- 函数连接两个写入缓冲区开头的字符串
- 使用QObject::connect()时,类型签名是否重要,用于将函数连接到信号
- 如何将Qt动作与函数连接起来
- 如何从一个线程发出信号,并将信号与一个单独的函数连接起来
- QT 5 connect()函数连接textEditor和主窗口