标签:获取 time cps qstring design vs2013 bsp deb str
使用qt函数获取网络时间
现在Qt Project Setting中的Qt Modules勾选NetWork,再导入头文件我也忘了叫什么了
1 QStringList net_time; 2 QTcpSocket *socket = new QTcpSocket(); 3 socket->connectToHost("time.windows.com", 13); 4 //connectToHost(url,port) //现在用这个不稳定,暂时没找到好的替代 5 if (socket->waitForConnected()) 6 { 7 if (socket->waitForReadyRead()) 8 { 9 QString str(socket->readAll()); 10 str = str.trimmed(); 11 str = str.section(" ", 1, 2); 12 qDebug() <<"str :"<< str; 13 } 14 else 15 { 16 //else 17 } 18 } 19 socket->close(); 20 delete socket;
标签:获取 time cps qstring design vs2013 bsp deb str
原文地址:https://www.cnblogs.com/HY12345/p/9899955.html