In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what is the use of Qt function names?" in the operation of actual cases, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Function name / / determine whether the IP address and port are online static bool ipLive (const QString & ip, int port, int timeout = 1000); / / get all the source code of the web page static QString getHtml (const QString & url); / / obtain the local public network IP address static QString getNetIP (const QString & webCode); / / obtain the native IP static QString getLocalIP (); / / convert the Url address to IP address static QString urlToIP (const QString & url) / / string completion static QString getValue (quint8 value); / / determine whether to access the extranet static bool isWebOk (); function body bool QUIHelper::ipLive (const QString & ip, int port, int timeout) {/ / local event loop, do not card the main interface QEventLoop eventLoop; / / set timeout QTimer timer; connect (& timer, SIGNAL (timeout ()), & eventLoop, SLOT (quit (); timer.setSingleShot (true) Timer.start (timeout); QTcpSocket tcpSocket; connect (& tcpSocket, SIGNAL (connected ()), & eventLoop, SLOT (quit ()); tcpSocket.connectToHost (ip, port); eventLoop.exec (); bool ok = (tcpSocket.state () = QAbstractSocket::ConnectedState); return ok;} QString QUIHelper::getHtml (const QString & url) {QNetworkAccessManager * manager = new QNetworkAccessManager (); QNetworkReply * reply = manager- > get (QNetworkRequest (QUrl (url); QByteArray responseData QEventLoop eventLoop; QObject::connect (manager, SIGNAL (finished (QNetworkReply *)), & eventLoop, SLOT (quit ()); eventLoop.exec (); responseData = reply- > readAll (); return QString (responseData);} QString QUIHelper::getNetIP (const QString & webCode) {QString web = webCode; web = web.replace (', "); web = web.replace ("\ r ",") Web = web.replace ("\ n", "); QStringList list = web.split ("); QString tar = list.at (3); QStringList ip = tar.split ("="); return ip.at (1);} QString QUIHelper::getLocalIP () {QStringList ips; QList addrs = QNetworkInterface::allAddresses (); foreach (QHostAddress addr, addrs) {QString ip = addr.toString () If (QUIHelper::isIP (ip)) {ips
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.