【文件属性】:
文件名称:产生随机数使用事件。-Qt简介包含Qt的系统的架构
文件大小:14.45MB
文件格式:PPT
更新时间:2021-04-24 03:05:19
qt教程
产生随机数,使用事件。
1.新建工程。在窗口上添加两个标签。
2.在main.cpp中添加代码,实现中文显示。
#include
QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
3.在mainwindow.h中添加代码。
void timerEvent(QTimerEvent *);
4.在mainwindow.cpp中添加代码。
添加头文件#include
在构造函数里添加以下代码。
startTimer(1000); //其返回值为1,即其timerId为1
startTimer(5000);//其返回值为2,即其timerId为2
startTimer(10000); //其返回值为3,即其timerId为3
添加了三个定时器,它们的timerId分别为1,2,3。注意,第几个定时器的返回值就为几。所以要注意定时器顺序。