QObject::startTimer: Timers cannot be started from another thread [使用自定义信号与曹函数来解决在子线程中不能调用QTimer定时器]
使用自定义信号与曹函数来解决在子线程中不能调用QTimer定时器
报错:
QObject::startTimer: Timers cannot be started from another thread
(此方法区别与其他博主给的方案,其他博主给的方案是在子线程中创建QTimer定时器,我的方法是用信号和槽来处理,此方法的好处是可以在子线程中开启定时器,在其他线程或主线程中关闭定时器)
如何在ros的 SimpleActionClient的回调函数子线程中调用主线程创建的QTimer定时器
实例 1 :
#ifndef VISUALORIENTATION_CarStartServuceClient_H
#define VISUALORIENTATION_CarStartServuceClient_H#include <Eigen/Geometry>
#include <opencv/cxeigen.hpp>
#include <opencv2/opencv.hpp>
#include <QtWidgets>
#include <QDebug>
#include <QComboBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "ros/ros.h"
#include <actionlib/client/simple_action_client.h>
#include "move_base_msgs/MoveBaseAction.h"
#include "move_base_msgs/Mo
QObject::startTimer: Timers cannot be started from another thread [使用自定义信号与曹函数来解决在子线程中不能调用QTimer定时器]相关推荐
- QObject::startTimer: Timers cannot be started from another thread
QObject::startTimer: Timers cannot be started from another thread 错误原因:QObject是可重入的,它的大多数非GUI子类,例如QT ...
- Qt笔记-解决QObject::startTimer: Timers cannot be started from another thread
原因是QTime或QTImeLine这类,多线程中创建和调用要在一个线程中. 因为构造函数在main线程中创建的,run是子线程中,所有,这部分代码的new要在run中去new就可以了.
- QObject::killTimer: Timers cannot be stopped from another thread
多线程中如果不慎重使用时间相关函数类如cv::waitkey(), QTimer()等, 如果没有管理好线程关系,容易导致时间混乱,报错可能是如下. QObject::killTimer: Timer ...
- Timers cannot be stopped from another thread
Timers cannot be stopped from another thread 我发现的一种情况: 线程异常退出了,并不是线程本身有问题,是线程里面报错了.
- 运行错误: QObject: 无法创建子线程, 因为父线程位于不同的线程? 到底是什么鬼?
运行错误: QObject: 无法创建子线程, 因为父线程位于不同的线程? 到底是什么鬼? (Parent is QThread(0x7ffe4a5a1280), parent's thread i ...
- QThread与QObject的关系
QThread与QObject的关系 Threads and QObjects QThread 继承 QObject..它可以发送started和finished信号,也提供了一些slot函数. QO ...
- 重点:怎样正确的使用QThread类(注:包括推荐使用QThread线程的新方法QObject::moveToThread)...
背景描述: 以前,继承 QThread 重新实现 run() 函数是使用 QThread唯一推荐的使用方法.这是相当直观和易于使用的.但是在工作线程中使用槽机制和Qt事件循环时,一些用户使用错了.Qt ...
- QObject: Cannot create children for a parent that is in a different thread
一篇又臭又长的流水账,要看结论可以直接拉到最后. 在一个项目中,需要使用串口接收外部的对射管状态,然后调用传感器.由于在之前的项目中,自制了一个带有UI的串口管理类(继承QDialog)最早在主线程中 ...
- 为何只能在其关联的线程内启动timer?
为何只能在其关联的线程内启动timer? 在QTimer源码分析(以Windows下实现为例) 一文中,我们谈到: QTimer的是通过QObject的timerEvent()实现的,开启和关闭定时器 ...
最新文章
- 您遵循过这些Jenkins优秀实践吗?
- 修改mysql表结构语句
- php加载外部html,VUE页面加载外部HTML实例详解
- LTDC/DMA2D—液晶显示
- 帮助罕见病患者买得到药 京东健康上线“罕见病关爱中心”
- 万年5W充电头再见!2019新iPhone或将标配18W快充头
- 【Flink】Flink 报错 ResourceManager leader changed to new address null
- mysql 写入性能瓶颈_如何通过性能调优突破MySQL数据库性能瓶颈?
- 类成员与方法访问控制从严
- python 安装第三方库/包(命令/详细注释),如安装pyinstaller库
- Android透明效果的实现
- stl之set集合容器应用基础
- 人工智能的下个十年在推理?
- JAVA开发类似冒险岛的游戏Part1
- 随心所欲生成git仓库随意一段commit的专用patch应用小实践
- 适合自学的C语言基础视频教程
- coq程序编写好用的IDE推荐
- 挑战华为社招:不止面试题,笔记源码统统都有,最强技术实现
- win10下Linux子系统(ubuntu)开启并配置(shell主题,设置中文环境,图形界面...)
- 790. 数的三次方根