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. [solved]Merge two QStringList elements
QtWS25 Last Chance

[solved]Merge two QStringList elements

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.9k 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.
  • A Offline
    A Offline
    AntonZelenin
    wrote on last edited by AntonZelenin
    #1

    Is there any opportunity to merge two elements of a QStringList?
    For example I have list "I", "have", "an", "apple" and i want to make such list: "I have", "an", "apple"

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

      There's no convenience function for that but it's pretty simple nonetheless:

      QString temp = stringList.takeAt(i);
      temp += stringList.takeAt(i)
      stringList.insert(i, temp);
      

      or even

      stringList[i] += stringList.takeAt(i+1);
      
      A 1 Reply Last reply
      1
      • Chris KawaC Chris Kawa

        There's no convenience function for that but it's pretty simple nonetheless:

        QString temp = stringList.takeAt(i);
        temp += stringList.takeAt(i)
        stringList.insert(i, temp);
        

        or even

        stringList[i] += stringList.takeAt(i+1);
        
        A Offline
        A Offline
        AntonZelenin
        wrote on last edited by
        #3

        @Chris-Kawa
        Thanks=)

        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