Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use the general method of Qt

Shulou Source: shulou.com Published: 2022-06-01 13:24:06 10月02日 Update

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

Tags: Binary character string method address learning legal content function byte two number that is train of thought situation article more phone number knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Redmi Shulou Information Linux Shulou Technology