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 Problem
QtWS25 Last Chance

Qstring Problem

Scheduled Pinned Locked Moved General and Desktop
5 Posts 5 Posters 1.7k 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.
  • M Offline
    M Offline
    maybnxtseasn
    wrote on last edited by
    #1

    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
    0
    • P Offline
      P Offline
      poporacer
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • M Offline
        M Offline
        msx_br
        wrote on last edited by
        #3

        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
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          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
          0
          • K Offline
            K Offline
            koahnig
            wrote on last edited by
            #5

            [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
            0

            • Login

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