Qt判斷QString中的字符串是否為純數字


  • /*** 
  •   *判斷一個字符串是否為純數字 
  •   */  
  • int Common::isDigitStr(QString src)  
  • {  
  •     QByteArray ba = src.toLatin1();//QString 轉換為 char*  
  •      const char *s = ba.data();  
  •   
  •     while(*s && *s>='0' && *s<='9') s++;  
  •   
  •     if (*s)  
  •     { //不是純數字  
  •         return -1;  
  •     }  
  •     else  
  •     { //純數字  
  •         return 0;  
  •     }  
  • }

  • 免責聲明!

    本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



     
    粵ICP備18138465號   © 2018-2025 CODEPRJ.COM