如題,專案中可能遇到此類問題,先寫個馬馬虎虎的解決方法:
第一種方法,逐一取中qstring的字元,進行判斷。
[html]
view plain
copy
qstring str;
int
ncount
= str
.count();
for(int i=
0; i
<
ncount
; i++)
}
第二種方法,是利用強大的正規表示式進行判斷。
[cpp]
view plain
copy
qstring str;
boolb = str.contains(qregexp(
"[\\x4e00-\\x9fa5]+"
));
if(b)
當然str這個物件,是要先有值了,這個值可以從qlineedit,qstanditem等等常用的其物件來。
下面是從網上查詢資料寫的拼音碼**:
boolin(wchar_t
start,
wchar_t
end,
wchar_t
code)
return
false;
}
charconvert(int
n)
qstringgetchinesespell(qstring
&src)
//獲得漢字拼音碼
else
//英文
}
return
strpinyin;
}
voiddqtx::on_lineedit_textchanged(const
qstring
&arg1)
{
qstring
strpy;
qstring
strpin;
strpin=arg1;
strpy=getchinesespell(strpin);
qdebug()<
qdebug()<
判斷QString中是否有漢字
如題,專案中可能遇到此類問題,先寫個馬馬虎虎的解決方法 第一種方法,逐一取中qstring的字元,進行判斷。qstring str int ncount str.count for int i 0 i ncount i 第二種方法,是利用強大的正規表示式進行判斷。qstring str bool b...
oracle 判斷值中是否存在漢字
with x as select 2320 fd少df,sr from dual union all select sr from dual union all select heleo sr from dual union all select 年 sr from dual union all s...
判斷輸入是否為漢字
判斷輸入是否為漢字 2008年03月27日 星期四 下午 08 10 列印 128到65535 漢字在unicode中的16進製製碼中在 u4e00 u9fa5 即 一 和 龥 private void button1 click object sender,eventargs e 龥 int 一 ...