<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # QStringList Class Reference ## [[QtCore](index.htm) module] QStringList中的類提供的字符串列表。[More...](#details) ### Methods * `__init__ (self)` * `__init__ (self, QString?i)` * `__init__ (self, QStringList?l)` * `append (self, QString?str)` * `clear (self)` * `bool contains (self, QString?str, Qt.CaseSensitivity?cs?=?Qt.CaseSensitive)` * `int count (self, QString?str)` * `int count (self)` * `QStringList filter (self, QString?str, Qt.CaseSensitivity?cs?=?Qt.CaseSensitive)` * `QStringList filter (self, QRegExp?rx)` * `QString first (self)` * `int indexOf (self, QString?value, int?from?=?0)` * `int indexOf (self, QRegExp?rx, int?from?=?0)` * `insert (self, int?i, QString?str)` * `bool isEmpty (self)` * `QString join (self, QString?sep)` * `QString last (self)` * `int lastIndexOf (self, QString?value, int?from?=?-1)` * `int lastIndexOf (self, QRegExp?rx, int?from?=?-1)` * `QStringList mid (self, int?pos, int?length?=?-1)` * `move (self, int?from, int?to)` * `prepend (self, QString?str)` * `int removeAll (self, QString?str)` * `removeAt (self, int?i)` * `int removeDuplicates (self)` * `replace (self, int?i, QString?str)` * `QStringList replaceInStrings (self, QString?before, QString?after, Qt.CaseSensitivity?cs?=?Qt.CaseSensitive)` * `QStringList replaceInStrings (self, QRegExp?rx, QString?after)` * `sort (self)` * `swap (self, int?i, int?j)` * `QString takeAt (self, int?i)` * `QString takeFirst (self)` * `QString takeLast (self)` ### Special Methods * `QStringList __add__ (self, QStringList?other)` * `int __contains__ (self, QString?str)` * `__delitem__ (self, int?i)` * `__delitem__ (self, slice?slice)` * `bool __eq__ (self, QStringList?other)` * `QString __getitem__ (self, int?i)` * `QStringList __getitem__ (self, slice?slice)` * `QStringList __iadd__ (self, QStringList?other)` * `QStringList __iadd__ (self, QString?value)` * `QStringList __imul__ (self, int?by)` * `__len__ (self)` * `QStringList __lshift__ (self, QString?str)` * `QStringList __lshift__ (self, QStringList?l)` * `QStringList __mul__ (self, int?by)` * `bool __ne__ (self, QStringList?other)` * `__setitem__ (self, int?i, QString?str)` * `__setitem__ (self, slice?slice, QStringList?list)` * * * ## Detailed Description Python字符串或Unicode對象的Python列表或[QString](qstring.html)實例可用于每當一個[QStringList](qstringlist.html)預計。 QStringList中的類提供的字符串列表。 QStringList中的繼承[QList](index.htm)\u003c[QString](qstring.html)\u003e 。喜歡[QList](index.htm), QStringList中是[implicitly shared](index.htm#implicitly-shared)。它提供了快速基于索引的訪問以及快速插入和刪除。傳遞字符串列表作為值參數既快速又安全。 所有[QList](index.htm)的功能也適用于QStringList中。例如,您可以使用[isEmpty](index.htm#isEmpty)( )來測試列表是否為空,你可以調用函數如[append](index.htm#append)( )[prepend](index.htm#prepend)( )[insert](index.htm#insert)( )[replace](index.htm#replace)( )[removeAll](index.htm#removeAll)( )[removeAt](index.htm#removeAt)( )[removeFirst](index.htm#removeFirst)( )[removeLast](index.htm#removeLast)()和[removeOne](index.htm#removeOne)( )來修改一個QStringList中。此外, QStringList中提供了一些方便的功能,使操作字符串容易列表: ### Adding strings 字符串可以使用被添加到列表中的[append()](index.htm#append),[operator+=](index.htm#operator-2b-eq)()和[operator&lt;&lt;](qstringlist.html#operator-lt-lt)()函數。例如: ``` QStringList fonts; fonts << "Arial" << "Helvetica" << "Times" << "Courier"; ``` ### Iterating over the strings 遍歷一個列表,你可以使用的索引位置,或[QList](index.htm)的Java風格和STL風格的迭代器類型: 索引: ``` for (int i = 0; i < fonts.size(); ++i) cout << fonts.at(i).toLocal8Bit().constData() << endl; ``` Java風格的迭代器: ``` [QStringListIterator](qstringlist.html#QStringListIterator-typedef) javaStyleIterator(fonts); while (javaStyleIterator.hasNext()) cout << javaStyleIterator.next().toLocal8Bit().constData() << endl; ``` STL風格的迭代器: ``` QStringList.const_iterator constIterator; for (constIterator = fonts.constBegin(); constIterator != fonts.constEnd(); ++constIterator) cout << (*constIterator).toLocal8Bit().constData() << endl; ``` 該[QStringListIterator](qstringlist.html#QStringListIterator-typedef)類只是一個類型定義[QListIterator](index.htm)\u003c[QString](qstring.html)\u003e 。 QStringList中還提供了[QMutableStringListIterator](qstringlist.html#QMutableStringListIterator-typedef)類,這是一個類型定義[QMutableListIterator](index.htm)\u003c[QString](qstring.html)\u003e 。 ### Manipulating the strings QStringList中提供了幾個功能,讓你操作一個列表的內容。您可以使用串連在一個字符串列表轉換成一個字符串的所有字符串(帶有可選的分隔符)的[join](qstringlist.html#join)()函數。例如: ``` [QString](qstring.html) str = fonts.join(","); // str == "Arial,Helvetica,Times,Courier" ``` 打破一個字符串轉換成一個字符串列表,使用[QString.split](qstring.html#split)( )函數: ``` QStringList list; list = str.split(","); // list: ["Arial", "Helvetica", "Times", "Courier"] ``` 該參數分割可以是單個字符,字符串,或[QRegExp](qregexp.html)。 此外,該[operator+](qstringlist.html#operator-2b)( )功能可讓您連接兩個字符串列表為一體。要排序的字符串列表,使用[sort](qstringlist.html#sort)()函數。 [QString](qstring.html)名單中還提供了[filter](qstringlist.html#filter)( )函數,它可以讓你提取一個新的列表,其中包含只有那些包含特定字符串(或匹配特定的正則表達式)字符串: ``` QStringList monospacedFonts = fonts.filter([QRegExp](qregexp.html)("Courier|Fixed")); ``` 該[contains](qstringlist.html#contains)( )函數告訴你的列表中是否包含給定的字符串,而[indexOf](qstringlist.html#indexOf)( )函數返回給定字符串的第一個匹配項的索引。該[lastIndexOf](qstringlist.html#lastIndexOf)在另一方面( )函數,返回字符串中最后一次出現的索引。 最后,該[replaceInStrings](qstringlist.html#replaceInStrings)( )函數調用[QString.replace](qstring.html#replace)( )在字符串列表中依次每個字符串。例如: ``` QStringList files; files << "$QTDIR/src/moc/moc.y" << "$QTDIR/src/moc/moc.l" << "$QTDIR/include/qconfig.h"; files.replaceInStrings("$QTDIR", "/usr/lib/qt"); // files: [ "/usr/lib/qt/src/moc/moc.y", ...] ``` * * * ## Method Documentation ``` QStringList.__init__ (self) ``` 構造一個空字符串列表。 ``` QStringList.__init__ (self, QString?i) ``` 構造一個字符串列表,其中包含給定的字符串,_str_。較長的列表很容易像這樣創建: ``` [QStringList](qstringlist.html) longerList = ([QStringList](qstringlist.html)() << str1 << str2 << str3); ``` **See also** [append](index.htm#append)( ) 。 ``` QStringList.__init__ (self, QStringList?l) ``` 構造的一個副本_other_字符串列表。 該操作需要[constant time](index.htm#constant-time)因為[QStringList](qstringlist.html) is [implicitly shared](index.htm#implicitly-shared),使得返回一個過程[QStringList](qstringlist.html)從非常快的函數。如果共享的實例被改性時,其將被復制(復制寫入時) ,而這需要[linear time](index.htm#linear-time)。 **See also** [operator=](index.htm#operator-eq)( ) 。 ``` QStringList.append (self, QString?str) ``` ``` QStringList.clear (self) ``` ``` bool QStringList.contains (self, QString?str, Qt.CaseSensitivity?cs?=?Qt.CaseSensitive) ``` 如果列表中包含該字符串,則返回True_str_否則返回False 。搜索不區分大小寫,如果_cs_ is [Qt.CaseInsensitive](qt.html#CaseSensitivity-enum);搜索是區分默認敏感。 **See also** [indexOf](qstringlist.html#indexOf)( )[lastIndexOf](qstringlist.html#lastIndexOf)()和[QString.contains](qstring.html#contains)( ) 。 ``` int QStringList.count (self, QString?str) ``` ``` int QStringList.count (self) ``` ``` QStringList QStringList.filter (self, QString?str, Qt.CaseSensitivity?cs?=?Qt.CaseSensitive) ``` 返回所有的字符串包含子列表_str_。 If _cs_ is [Qt.CaseSensitive](qt.html#CaseSensitivity-enum)(默認值) ,字符串比較是區分大小寫的,否則比較不區分大小寫。 ``` [QStringList](qstringlist.html) list; list << "Bill Murray" << "John Doe" << "Bill Clinton"; [QStringList](qstringlist.html) result; result = list.filter("Bill"); // result: ["Bill Murray", "Bill Clinton"] ``` 這等效于 ``` [QStringList](qstringlist.html) result; foreach (const [QString](qstring.html) &str, list) { if (str.contains("Bill")) result += str; } ``` **See also** [contains](qstringlist.html#contains)( ) 。 ``` QStringList QStringList.filter (self, QRegExp?rx) ``` 這是一個重載函數。 返回所有匹配正則表達式的字符串列表_rx_。 ``` QString QStringList.first (self) ``` ``` int QStringList.indexOf (self, QString?value, int?from?=?0) ``` 返回的第一個精確匹配的索引位置_rx_在列表中,向前搜索從索引位置_from_。返回-1,如果沒有項目匹配。 默認情況下,這個功能是區分大小寫的。 **See also** [lastIndexOf](qstringlist.html#lastIndexOf)( )[contains](qstringlist.html#contains)()和[QRegExp.exactMatch](qregexp.html#exactMatch)( ) 。 ``` int QStringList.indexOf (self, QRegExp?rx, int?from?=?0) ``` 返回第一次出現的索引位置_value_在列表中,向前搜索從索引位置_from_。返回-1,如果沒有項目匹配。 **See also** [lastIndexOf](qstringlist.html#lastIndexOf)( )[contains](qstringlist.html#contains)()和[QList.indexOf](index.htm#indexOf)( ) 。 ``` QStringList.insert (self, int?i, QString?str) ``` ``` bool QStringList.isEmpty (self) ``` ``` QString QStringList.join (self, QString?sep) ``` 加入所有的字符串列表的字符串與由給定的分隔每個元素的單個字符串_separator_(可以是空字符串) 。 **See also** [QString.split](qstring.html#split)( ) 。 ``` QString QStringList.last (self) ``` ``` int QStringList.lastIndexOf (self, QString?value, int?from?=?-1) ``` 返回的最后一個精確匹配的索引位置_rx_在列表中,從索引位置向后搜索_from_。如果_from_為-1 (默認值) ,該搜索從最后一個項目。返回-1,如果沒有項目匹配。 默認情況下,這個功能是區分大小寫的。 **See also** [indexOf](qstringlist.html#indexOf)( )[contains](qstringlist.html#contains)()和[QRegExp.exactMatch](qregexp.html#exactMatch)( ) 。 ``` int QStringList.lastIndexOf (self, QRegExp?rx, int?from?=?-1) ``` 返回最后一次出現的索引位置_value_在列表中,從索引位置向后搜索_from_。如果_from_為-1 (默認值) ,該搜索從最后一個項目。返回-1,如果沒有項目匹配。 默認情況下,這個功能是區分大小寫的。 **See also** [indexOf](qstringlist.html#indexOf)()和[QList.lastIndexOf](index.htm#lastIndexOf)( ) 。 ``` QStringList QStringList.mid (self, int?pos, int?length?=?-1) ``` ``` QStringList.move (self, int?from, int?to) ``` ``` QStringList.prepend (self, QString?str) ``` ``` int QStringList.removeAll (self, QString?str) ``` ``` QStringList.removeAt (self, int?i) ``` ``` int QStringList.removeDuplicates (self) ``` 此函數刪除重復項列表。條目不必進行排序。他們將保留原來的順序。 返回刪除條目的數量。 此功能被引入Qt的4.5 。 ``` QStringList.replace (self, int?i, QString?str) ``` ``` QStringList QStringList.replaceInStrings (self, QString?before, QString?after, Qt.CaseSensitivity?cs?=?Qt.CaseSensitive) ``` 返回一個字符串列表,其中每個字符串發生了_before_文本與替換_after_文本的地方_before_文字被發現。該_before_文本匹配大小寫敏感或不依賴于_cs_標志。 例如: ``` [QStringList](qstringlist.html) list; list << "alpha" << "beta" << "gamma" << "epsilon"; list.replaceInStrings("a", "o"); // list == ["olpho", "beto", "gommo", "epsilon"] ``` **See also** [QString.replace](qstring.html#replace)( ) 。 ``` QStringList QStringList.replaceInStrings (self, QRegExp?rx, QString?after) ``` 這是一個重載函數。 取代了正則表達式的每個實例_rx_在每個字符串列表的字符串,以_after_。返回一個引用的字符串列表。 例如: ``` [QStringList](qstringlist.html) list; list << "alpha" << "beta" << "gamma" << "epsilon"; list.replaceInStrings([QRegExp](qregexp.html)("^a"), "o"); // list == ["olpha", "beta", "gamma", "epsilon"] ``` 對于包含正則表達式[capturing parentheses](qregexp.html#capturing-parentheses),出現的**\1**,**\2**,...,在_after_被替換為_rx_。帽( 1 ) ,_rx_。蓋(2 ) , ... 例如: ``` [QStringList](qstringlist.html) list; list << "Bill Clinton" << "Murray, Bill"; list.replaceInStrings([QRegExp](qregexp.html)("^(.*), (.*)$"), "\\2 \\1"); // list == ["Bill Clinton", "Bill Murray"] ``` ``` QStringList.sort (self) ``` 按升序排列(敏感的情況下)的字符串列表。 使用Qt的進行排序[qSort](index.htm#qSort)( )算法,該算法在運行[linear-logarithmic time](index.htm#linear-logarithmic-time),即澳(_n_登錄_n_) 。 如果你想以任意順序的字符串進行排序,請考慮使用[QMap](index.htm)類。例如,您可以使用[QMap](index.htm)\u003c[QString](qstring.html),[QString](qstring.html)\u003e創建一個不區分大小寫的排序(例如,使用按鍵作為字符串的小寫版本,并作為字符串值) ,或[QMap](index.htm)\u003c整數,[QString](qstring.html)\u003e由一些整數索引的字符串進行排序。 **See also** [qSort](index.htm#qSort)( ) 。 ``` QStringList.swap (self, int?i, int?j) ``` ``` QString QStringList.takeAt (self, int?i) ``` ``` QString QStringList.takeFirst (self) ``` ``` QString QStringList.takeLast (self) ``` ``` QStringList QStringList.__add__ (self, QStringList?other) ``` ``` int QStringList.__contains__ (self, QString?str) ``` ``` QStringList.__delitem__ (self, int?i) ``` ``` QStringList.__delitem__ (self, slice?slice) ``` ``` bool QStringList.__eq__ (self, QStringList?other) ``` ``` QString QStringList.__getitem__ (self, int?i) ``` ``` QStringList QStringList.__getitem__ (self, slice?slice) ``` ``` QStringList QStringList.__iadd__ (self, QStringList?other) ``` ``` QStringList QStringList.__iadd__ (self, QString?value) ``` ``` QStringList QStringList.__imul__ (self, int?by) ``` ``` QStringList.__len__ (self) ``` ``` QStringList QStringList.__lshift__ (self, QString?str) ``` ``` QStringList QStringList.__lshift__ (self, QStringList?l) ``` ``` QStringList QStringList.__mul__ (self, int?by) ``` ``` bool QStringList.__ne__ (self, QStringList?other) ``` ``` QStringList.__setitem__ (self, int?i, QString?str) ``` ``` QStringList.__setitem__ (self, slice?slice, QStringList?list) ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看