Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Behind the Scenes
  3. Wiki Discussion
  4. QString::arg Documentation Confusion

QString::arg Documentation Confusion

Scheduled Pinned Locked Moved Solved Wiki Discussion
8 Posts 4 Posters 2.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ResistorInTheDarkR Offline
    ResistorInTheDarkR Offline
    ResistorInTheDark
    wrote on last edited by ResistorInTheDark
    #1

    This post has to do with my confusion (and potentially the confusion of others) over a particular QString::arg documentation.

    I'm not sure where to put this post so I decided to throw it in wiki discussion.

    The last example of the section states

    QString str;
    str = "%1%2%3";
    str.arg("Hello", QString::number(20), QString::number(50)); // returns "Hello5020"
    

    I'm rather confused. Shouldn't it either be
    str = "%1%3%2"; (line 2)
    or
    // returns "Hello2050" (line 3)?

    I'm sort of inferring that it's supposed to be str = "%1%3%2"; from the point its trying to make. I'm hoping that someone can clarify this for me and perhaps fix it.

    Thanks for any clarifications.

    Gojir4G aha_1980A 2 Replies Last reply
    0
    • ResistorInTheDarkR ResistorInTheDark

      This post has to do with my confusion (and potentially the confusion of others) over a particular QString::arg documentation.

      I'm not sure where to put this post so I decided to throw it in wiki discussion.

      The last example of the section states

      QString str;
      str = "%1%2%3";
      str.arg("Hello", QString::number(20), QString::number(50)); // returns "Hello5020"
      

      I'm rather confused. Shouldn't it either be
      str = "%1%3%2"; (line 2)
      or
      // returns "Hello2050" (line 3)?

      I'm sort of inferring that it's supposed to be str = "%1%3%2"; from the point its trying to make. I'm hoping that someone can clarify this for me and perhaps fix it.

      Thanks for any clarifications.

      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by
      #2

      @ResistorInTheDark Hi,

      It looks like a mistake in the documentation. From the context, we can guess that it should be:

      String str;
      str = "%1%3%2";
      str.arg("Hello", QString::number(20), QString::number(50)); // returns "Hello5020"
      
      JonBJ 1 Reply Last reply
      4
      • ResistorInTheDarkR Offline
        ResistorInTheDarkR Offline
        ResistorInTheDark
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • Gojir4G Gojir4

          @ResistorInTheDark Hi,

          It looks like a mistake in the documentation. From the context, we can guess that it should be:

          String str;
          str = "%1%3%2";
          str.arg("Hello", QString::number(20), QString::number(50)); // returns "Hello5020"
          
          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Gojir4
          I believe the format string was correct/intended, and the comment for the output is what was incorrect.... :)

          Gojir4G 1 Reply Last reply
          0
          • JonBJ JonB

            @Gojir4
            I believe the format string was correct/intended, and the comment for the output is what was incorrect.... :)

            Gojir4G Offline
            Gojir4G Offline
            Gojir4
            wrote on last edited by
            #5

            @JonB I don't think so. They are demonstrating why you need to be careful when using disordered arguments. See the full chapter. So I stay on my position.

            1 Reply Last reply
            3
            • ResistorInTheDarkR ResistorInTheDark

              This post has to do with my confusion (and potentially the confusion of others) over a particular QString::arg documentation.

              I'm not sure where to put this post so I decided to throw it in wiki discussion.

              The last example of the section states

              QString str;
              str = "%1%2%3";
              str.arg("Hello", QString::number(20), QString::number(50)); // returns "Hello5020"
              

              I'm rather confused. Shouldn't it either be
              str = "%1%3%2"; (line 2)
              or
              // returns "Hello2050" (line 3)?

              I'm sort of inferring that it's supposed to be str = "%1%3%2"; from the point its trying to make. I'm hoping that someone can clarify this for me and perhaps fix it.

              Thanks for any clarifications.

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi @ResistorInTheDark and @Gojir4

              thanks for your findings and conclusions. I've prepared a patch to fix the documentation: https://codereview.qt-project.org/238951

              Please note that in future you can do discussions about (assumed) bugs here, but the final report should be at bugreports.qt.io, so they are not lost.

              Thanks and regards.

              Qt has to stay free or it will die.

              aha_1980A 1 Reply Last reply
              3
              • aha_1980A aha_1980

                Hi @ResistorInTheDark and @Gojir4

                thanks for your findings and conclusions. I've prepared a patch to fix the documentation: https://codereview.qt-project.org/238951

                Please note that in future you can do discussions about (assumed) bugs here, but the final report should be at bugreports.qt.io, so they are not lost.

                Thanks and regards.

                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by
                #7

                so, the patch got merged and will be in 5.11.2 or 5.12.

                So we can close this topic.

                Qt has to stay free or it will die.

                Gojir4G 1 Reply Last reply
                1
                • aha_1980A aha_1980

                  so, the patch got merged and will be in 5.11.2 or 5.12.

                  So we can close this topic.

                  Gojir4G Offline
                  Gojir4G Offline
                  Gojir4
                  wrote on last edited by
                  #8

                  @aha_1980 Thanks for haviing handling this. Good job

                  1 Reply Last reply
                  2

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved