Qt计时器可以达到2毫秒以下的精度吗?求高手指点
发布网友
发布时间:2022-05-30 17:19
我来回答
共1个回答
热心网友
时间:2023-10-21 12:25
代码修改如下:
Option Explicit
Private Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) '传回本地时间
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Dim SysTime As SYSTEMTIME
Private Sub Form_Load()
Text1.Text = "00:00:00:00"
Command1.Caption = "开始"
Command2.Caption = "结束"
Command2.Enabled = False
Timer1.Interval = 1
Timer1.Enabled = False
End Sub
Private Sub Command1_Click()
If Command1.Caption = "开始" Then
Timer1.Enabled = True
Command1.Caption = "暂停"
Command2.Enabled = True
ElseIf Command1.Caption = "暂停" Then
Timer1.Enabled = False
Command1.Caption = "继续"
ElseIf Command1.Caption = "继续" Then
Timer1.Enabled = True
Command1.Caption = "暂停"
End If
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
Command2.Enabled = False
Text1.Text = "00:00:00:00"
Command1.Caption = "开始"
Command1.SetFocus
End Sub
Private Sub Timer1_Timer()
GetLocalTime SysTime
Text1.Text = SysTime.wHour & ":" & Format(SysTime.wMinute, "0#") & ":" & Format(SysTime.wSecond, "0#") & ":" & SysTime.wMilliseconds
End Sub追问非常感谢您的热心回复。但我现在还看不懂这些代码,只是以后控制中会用到达到2毫秒以下的计时器。请你直接告诉我Qt能否达到2毫秒以下的计时精度要求。谢谢!