当前位置:网站首页>1. A complete instance of movetothread, 2. QT expression evaluation
1. A complete instance of movetothread, 2. QT expression evaluation
2022-07-22 18:54:00 【Moon cave】
1.moveToThread A complete instance of
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
Timer *timer = new Timer;
timer->setInterval(1000);
THread *t = new THread(this);
timer->moveToThread(t);
connect(t, SIGNAL(started()), timer, SLOT(start()));
connect(t, SIGNAL(finished()), timer, SLOT(deleteLater()));
connect(timer, SIGNAL(timeout()), this ,SLOT(print()));
//
t->start();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::print()
{
qDebug()<<"timeout";
}
// Self defined Timer
Timer::~Timer()
{
qDebug()<< __FUNCTION__;
}
//THread
THread::~THread()
{
this->quit();
this->wait();
qDebug()<< __FUNCTION__;
}
2.qt Expression evaluation
QScriptEngine().evaluate("3 + Math.sqrt(5) + Math.pow(3,2) + Math.log(5)").toNumber()
边栏推荐
猜你喜欢
1.雷点:mysql数据库转移到oracle,2.qt5.12.3 连接oracle 12c数据库
六度空间
NRF24L01无线模块设置发射接受模式方法
NRF24L01 wireless module setting transmit receive mode method
1.常量中有换行符Qt5-》vs的解决方案;2.同一份代码Qt和vs共同编译的问题和解决方案
在各类数据库中随机查询n条数据
PTA 基础题7-28猴子选大王(简单方法)
PTA基础题 7-23 币值转换 (20 分) (属实恶心)
Important knowledge points of go language: string, UTF-8 encoding, Rune
VLFeat、pydot配置
随机推荐
Over the weekend, I had a dinner with the technology gurus and talked about the "golden nine and silver ten" peak of the software testing industry [the trend of involution has been formed]
【QT源代码复用】模拟QCompleter的弹窗方式
(c语言)数组是一种特殊的指针?
六度空间
1.QTableWidget的closable,2.pro/build_pass、member,3.QString&&
LeetCode:626. 换座位
Solve the problem that the target bytecode version number of IntelliJ cannot be maintained
LeetCode 114. 二叉树展开为链表
预算dll要达到的效果,Qt将第三方窗口嵌入程序内,excel操作,数据库外键,判断程序是否启动
02. Dependency Inversion Principle
Leetcode 116. fill in the next right node pointer of each node
练习7-7 矩阵运算 (20 分)
No input file specified solution
LeetCode: 184. 部门工资最高的员工
PTA基础题 7-23 币值转换 (20 分) (属实恶心)
连接mysql8.0出现caching-sha2-password问题
QT | modal dialog and modeless dialog qdialog
PTA搜索树判断
Thymeleaf中一个页面怎么嵌套另一个页面,关于页面嵌套,标签告诉你应该知道的
实现各个微服务间限制IP访问 的三种方式