Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    QString::mid question

    General and Desktop
    4
    5
    796
    Loading More Posts
    • 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.
    • RIVOPICO
      RIVOPICO last edited by RIVOPICO

      Hi i checked all but one thing i never can get is for example i have this string.
      QString string= "change"
      "abcde"+ string + "ijklm"
      Sometimes the length of my string change. How i can start counting since right and get complet string for example i start since letter k so i will get:
      "abcde"+ change + "ijk"

      Sorry if i was explaining bad but i want to count since right with mid. thx

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Do you mean get the length length of "ijk" or get the length of "abcde" + some_string + "ijk" ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        RIVOPICO 1 Reply Last reply Reply Quote 2
        • RIVOPICO
          RIVOPICO @SGaist last edited by

          @SGaist said in QString::mid question:

          "abcde" + some_string + "ijk"

          "abcde" + some_string + "ijk" if the some_string change each time the length.

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User last edited by

            This will return the number of code points of the combined string:

            QString("%1%2%3").arg(first_string).arg(second_string).arg(third_string).size()

            1 Reply Last reply Reply Quote 3
            • Paul Colby
              Paul Colby last edited by

              I think what @RIVOPICO is trying to say (I could be completely wrong), is:

              • he already has a string like abcdesome_stringijklm
              • he wants to use QString::mid() to extract just some_string, but of course, QString::mid() requires a substring lengh, which is unknown in this case.

              If I read @RIVOPICO correctly, then he could do something like: string.mid(6, string.length()-11); ?

              1 Reply Last reply Reply Quote 3
              • First post
                Last post