Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Qstring Problem

    General and Desktop
    5
    5
    1478
    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.
    • M
      maybnxtseasn last edited by

      Say i have a Qstring of the following

      QString str1 = "HelloWorldThere";

      How would i go about extracting the characters from index 2 all the way to index 7 within the string so i can effectively retrieve this sing.

      Qstring extractedString = "lloWor";

      Pretty much i just want to extract a string from within a string when i have a starting index and an ending index. Any help is greatly appreciated

      1 Reply Last reply Reply Quote 0
      • P
        poporacer last edited by

        QString y = str1.mid(1, 6);

        1 Reply Last reply Reply Quote 0
        • M
          msx_br last edited by

          I think QRegExp class can help you:

          "QRegExp Class Reference":http://qt-project.org/doc/qt-4.8/qregexp.html

          msx_br - Brazil (Netherlands)

          1 Reply Last reply Reply Quote 0
          • A
            andre last edited by

            QRegExp is worthless for this situation. Please try not to confuse users with random answers that are vaguely related. poporacer suggests the right approach.

            1 Reply Last reply Reply Quote 0
            • K
              koahnig last edited by

              [quote author="poporacer" date="1332042095"] QString y = str1.mid(1, 6);[/quote]
              This is the right approach, but it should be:
              @ QString y = str1.mid(2, 6);@

              Vote the answer(s) that helped you to solve your issue(s)

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