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. Handling several QStringLists
QtWS25 Last Chance

Handling several QStringLists

Scheduled Pinned Locked Moved Solved General and Desktop
qtcreatorqstringlistdatastructures
5 Posts 4 Posters 1.5k 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.
  • L Offline
    L Offline
    Lasith
    wrote on 27 Sept 2017, 18:21 last edited by Lasith
    #1

    In the application I am currently developing I want to store several QStringLists in a single QStringList!

    eg-
    QStringList a;
    QStringList b;
    QStringList c;

    b<<"John"<<"Smith"<<"Peter";
    c<<"Mary"<<"Anne"<<"Marie";
    a<<b<<c;
    Compiling this code does not return any errors but when I print a[0] on a label only "John" is printed instead of "John Smith Peter"
    I want to store 'b' and 'c' in 'a'!What is the best data structure to achive this?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Pablo J. Rogina
      wrote on 27 Sept 2017, 19:33 last edited by
      #2

      @Lasith try checking what printing b[0], b[1] and b[2] show just before adding b and c lists to a, and I guess you'll have the answer...

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 27 Sept 2017, 20:37 last edited by
        #3

        Hi,

        Looks like you should use QString::join.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        L 1 Reply Last reply 28 Sept 2017, 01:43
        2
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 27 Sept 2017, 21:29 last edited by
          #4

          Hi
          There is something odd about your statements.
          You say you want lists in the list.
          But you also say you expect "John Smith Peter" which is not a list but one string.
          So are you saying you want the lists b and c to become one string and no longer be a list of 3 strings?

          Anyway, seems @SGaist is a master guesser :) \o/

          1 Reply Last reply
          0
          • S SGaist
            27 Sept 2017, 20:37

            Hi,

            Looks like you should use QString::join.

            L Offline
            L Offline
            Lasith
            wrote on 28 Sept 2017, 01:43 last edited by
            #5

            @SGaist Thanx mate

            1 Reply Last reply
            0

            5/5

            28 Sept 2017, 01:43

            • Login

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