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 find
Forum Updated to NodeBB v4.3 + New Features

qstring find

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 606 Views 1 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.
  • S Offline
    S Offline
    s002wjh
    wrote on last edited by
    #1

    how would I find / and extract word before and after the / for example
    QString a = "hello/test"

    extract hello and test base on / separation?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2
      QVector<QStringRef> words = a.splitRef('/');
      
      1 Reply Last reply
      1
      • S Offline
        S Offline
        s002wjh
        wrote on last edited by s002wjh
        #3

        so word[0] would be "hello", word[1]=test?

        Chris KawaC 1 Reply Last reply
        0
        • S s002wjh

          so word[0] would be "hello", word[1]=test?

          Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @s002wjh Yes. Obviously check first if the vector actually has 2 elements in case there's no / in the string.

          1 Reply Last reply
          1
          • S Offline
            S Offline
            s002wjh
            wrote on last edited by
            #5

            if I want to assign words[0] to another string is it?

            QString tt=words[0];? I'm getting error on this

            1 Reply Last reply
            0
            • Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by
              #6

              words[0] is a QStringRef, so to assign it to a QString you do QString tt = words[0].toString();.

              1 Reply Last reply
              4

              • Login

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