Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the general method of Qt

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use the general method of Qt". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use the general method of Qt".

Function name / / determine whether it is an IP address static bool isIP (const QString & ip); / / determine whether it is a MAC address static bool isMac (const QString & mac); / / determine whether it is a legitimate phone number static bool isTel (const QString & tel); / / determine whether it is a legitimate email address static bool isEmail (const QString & email) / / hexadecimal string to decimal static int strHexToDecimal (const QString & strHex); / / decimal string to decimal static int strDecimalToDecimal (const QString & strDecimal); / / 2 string to decimal static int strBinToDecimal (const QString & strBin); / / hexadecimal string to binary string static QString strHexToStrBin (const QString & strHex) / / 10 to binary string one byte static QString decimalToStrBin1 (int decimal); / 10 to binary string two bytes static QString decimalToStrBin2 (int decimal); / 10 to hexadecimal string, zero. Static QString decimalToStrHex (int decimal); function body bool QUIHelper::isIP (const QString & ip) {QRegExp RegExp ("((2 [0-4]\ d | 25 [0-5] | [01]?\\ d\\ d?)) {3} (2 [0-4]\\ d | 25 [0-5] | [01]?\\ d\\ d?)); return RegExp.exactMatch (ip) } bool QUIHelper::isMac (const QString & mac) {QRegExp RegExp ("^ [A-F0-9] {2} (- [A-F0-9] {2}) {5} $"); return RegExp.exactMatch (mac);} bool QUIHelper::isTel (const QString & tel) {if (tel.length ()! = 11) {return false } if (! tel.startsWith ("13") & &! tel.startsWith ("14") & &! tel.startsWith ("15") & &! tel.startsWith ("18") {return false;} return true;} bool QUIHelper::isEmail (const QString & email) {if (! email.contains ("@") |! email.contains (".com")) {return false;} return true } int QUIHelper::strHexToDecimal (const QString & strHex) {bool ok; return strHex.toInt (& ok, 16);} int QUIHelper::strDecimalToDecimal (const QString & strDecimal) {bool ok; return strDecimal.toInt (& ok, 10);} int QUIHelper::strBinToDecimal (const QString & strBin) {bool ok; return strBin.toInt (& ok, 2);} QString QUIHelper::strHexToStrBin (const QString & strHex) {uchar decimal = strHexToDecimal (strHex); QString bin = QString::number (decimal, 2) Uchar len = bin.length (); if (len < 8) {for (int I = 0; I < 8-len; iTunes +) {bin = "0" + bin;}} return bin;} QString QUIHelper::decimalToStrBin1 (int decimal) {QString bin = QString::number (decimal, 2); uchar len = bin.length (); if (len

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report