From 8a2239a0376826739d4fa1066d483a531d5c407a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BE=AF=E7=BA=A2=E5=8B=8B?= <houhongxun@kylinos.cn>
Date: Mon, 6 May 2024 14:10:34 +0800
Subject: [PATCH] use QRandomGenerator, and fix code error
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: 侯红勋 <houhongxun@kylinos.cn>
---
 model/dataparser.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/model/dataparser.cpp b/model/dataparser.cpp
index 3719334..a733b29 100644
--- a/model/dataparser.cpp
+++ b/model/dataparser.cpp
@@ -1,5 +1,5 @@
 #include "dataparser.h"
-
+#include <QRandomGenerator>
 DataParser::DataParser() {}
 
 //处理返回的网络数据
@@ -309,10 +309,11 @@ void DataParser::hourlyWeather(QJsonObject hourlyObj, QList<Hourly> hourlist)
 void DataParser::tmphourlyWeather(QJsonObject hourlyObj, QList<Hourly> hourlist)
 {
     QTime current_time = QTime::currentTime();
+    QRandomGenerator rnd(current_time.msecsSinceStartOfDay());
     int hour = current_time.hour() + 1; //当前的小时
     for (int i = 0; i < 24; i++) {
-        int num_code = qrand() % (1, 60);
-        int num_tmp = qrand() % (-10, 30);
+        int num_code = rnd.bounded(0, 61);
+        int num_tmp = rnd.bounded(-10, 31);
         QString tmpText = QString::number(num_tmp) + "°C";
         Hourly tmp_hour;
         QString hour_tmp = QString::number(hour + i) + ":00";
-- 
2.43.0

