Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-63485

Documentation for QStringList::replaceInStrings

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.9.0, 5.9.1
    • Documentation
    • None

    Description

      The documentation for QStringList::replaceInStrings does not specify the effects when an empty string is provided for the before argument, since the outcome is not what IMHO most of the developers would expect.

      Here is the example:

      QStringList mylist; 
      mylist << "ONE" << "TWO"<<"THREE"; 
      QString after = "dummy"; 
      QString before; // same with QString before=""; qDebug()<< mylist; 
      mylist.replaceInStrings(before, after); 
      qDebug()<< mylist; 

      which results in an output:

      ("ONE", "TWO", "THREE") 
      ("dummyOdummyNdummyEdummy", "dummyTdummyWdummyOdummy", "dummyTdummyHdummyRdummyEdummyEdummy")

      Based on the discussion on forum.qt.io, this kind of behavior would come in handy when one would want to put something between characters (blatantly copied one of the replies made by jsulm).

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            docteam Qt Documentation Team
            fantaz fantaz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes