Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QString::mid question
Forum Updated to NodeBB v4.3 + New Features

QString::mid question

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 1.9k Views 3 Watching
  • 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.
  • RIVOPICOR Offline
    RIVOPICOR Offline
    RIVOPICO
    wrote on last edited by RIVOPICO
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      RIVOPICOR 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi,

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

        RIVOPICOR Offline
        RIVOPICOR Offline
        RIVOPICO
        wrote on last edited by
        #3

        @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
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          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
          3
          • Paul ColbyP Offline
            Paul ColbyP Offline
            Paul Colby
            wrote on last edited by
            #5

            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
            3

            • Login

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