Qt中的QString類

來源:互聯網
上載者:User

QString字串類
QString類提供一個unicode文本和經典的C中以零結果的字元數組的抽象
QString::QString()
構造一個零字串
QString::QString(QChar ch)
構造一個長度為一個字元,內容為給定字元ch的字串
QString::QString(const QString &s)
構造一個給定字元序列的字串
QString & QString::append(const QString &str)
QString & QString::append ( char ch )
QString & QString::append ( QChar ch )
追加str字串並返回結果的引用
QChar QString::at(uint i)const
返回索引i處的字元,數組從0開始
int QString::compare(const QString &s1,const QString &s2)靜態
比較兩個字串,返回大於0小於0等於0的整數
int QString::contains(QChar c,bool cs=TRUE)const
返回在這個字串中字元c出現的次數,如果cs為真則區分大小寫
bool QString::endsWith(const QString &s)const
如果字串以s結尾返回真
QString & QString::fill(QChar c,int len=-1)
填充字串為len個字元的值c並返回引用
int QString::find(const QRegExp &rx,int index=0)const
從位置index處開始搜尋Regexrx並返回位置
bool QString::isEmpty() const
如果字串為空白返回真
bool QString::isNull()const
如果字串為零返回真
QString QString::left(uint len)const
返回包含字串最左邊len個字元的子串
uint QString::length() const
返回字串的長度,零字串和空串返回0
int QString::localAwareCompare(const QString &s1,const QString &s2)靜態
基於本地的並且基於平台的字串比較函數
QString QString::lower()const
返回該字串的小寫串
QString QString::mid(uint index,uint len)const
返回從index處開始的len個長度的子串
QString QString::number(long n,int base=10)靜態
把數字n轉換為基數為base的字串
QString QString::right(uint len)const
返回最右邊的len個長度的子串
QString & QString::sprintf(const char *cformat,...)
從一個格式化字串cformat和一個任意參數列表安全地構建一個格式化的字串
bool QString::startsWith(const QString &s)const
如果字串以s開頭,返回真
double QString::toDouble(bool *ok=0)const
將字串轉換為雙精確度數字型
如果發生錯誤,*ok被設定為假,否則為真
float QString::toFloat(bool *ok=0)const
將字串轉換為單精確度數值型
如果發生錯誤,*ok被設定為假,否則為真
int QString::toInt(bool *ok=0,int base=10)const
將字串轉換為整型,基於base進位
long QString::toLong ( bool * ok = 0, int base = 10 ) const
short QString::toShort ( bool * ok = 0, int base = 10 ) const
uint QString::toUInt ( bool * ok = 0, int base = 10 ) const
ulong QString::toULong ( bool * ok = 0, int base = 10 ) const
ushort QString::toUShort ( bool * ok = 0, int base = 10 ) const
QString QString::upper() const
返回這個字串的大寫字串
QCString QString::utf8() const
返回按UTF8格式編碼的字串

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.