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]QStringlist - strings missing in long list
Forum Updated to NodeBB v4.3 + New Features

[Solved]QStringlist - strings missing in long list

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 2.5k 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
    satishshenoy
    wrote on last edited by
    #1

    Hi,

    Am fetching large data ( more than 30K records( only 1 column)) from database and keeping in QStringlist container for further processing and i found that some records went missing. The total items in the list are not matching with the records i got from the database.

    Facing the same problem with QHash and QMap because of collision and it seems QStringlist is also using QHash in its internal implementation.

    so i want to know.

    • Is this is a bug or limitation of QStringlist
    • Is there any other way to store large data without loss.
    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Data is stored with signed int indexes (definitely for QList and QVector, I'm not sure about the implementation of QHash and QMap), so when you go beyond that, you are on your own. You can try STL containers, or any other solution that is prepared for big amounts of data. As this is a special use-case, not required in most applications, Qt Project has no interest in making containers use an unsigned int or quint64.

      (Z(:^

      1 Reply Last reply
      0
      • JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        A signed 32-bit int can still go up to 2,147,483,647 so I doubt 30K is an issue.

        • How are you fetching the data?
        • How can you tell that collisions happened?

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        0
        • JeroentjehomeJ Offline
          JeroentjehomeJ Offline
          Jeroentjehome
          wrote on last edited by
          #4

          Might this have to do with thread workings? Do you use multithreading? QStringList is NOT threadsafe!
          It shouldn't be a problem to store 30k of data in a stringlist. I would advise to use a QList of QString * instead. The StringList will otherwise consume a large chunck of your stack. Using 'new' and the pointers to it will use the heap, which is as large as what your OS gives you.

          Greetz, Jeroen

          1 Reply Last reply
          0
          • JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            [quote author="Jeroentje@home" date="1383127266"]Might this have to do with thread workings? Do you use multithreading? QStringList is NOT threadsafe![/quote]Good thinking. Yes, that's a very possible cause.

            [quote]I would advise to use a QList of QString * instead. The StringList will otherwise consume a large chunck of your stack. Using 'new' and the pointers to it will use the heap, which is as large as what your OS gives you. [/quote]Incorrect. Qt containers (including QList AND QString) all store their internal data on the heap.

            On a stack:

            • A QString, no matter how long, occupies the same amount of space as a pointer.
            • A QList, no matter how large, occupies the same amount of space as a pointer.

            That's how Qt containers can be "implicitly shared":http://qt-project.org/doc/qt-5.1/qtcore/implicit-sharing.html. There is never any need to call new QString().

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            0
            • S Offline
              S Offline
              satishshenoy
              wrote on last edited by
              #6

              Thanks you all for your suggestions.

              Yes i was using multithread and even increased thread counts and was updating a single list. now i used mutex at time of updating list and its working fine.

              1 Reply Last reply
              0
              • JeroentjehomeJ Offline
                JeroentjehomeJ Offline
                Jeroentjehome
                wrote on last edited by
                #7

                Qt containers are great, but still I prefer to do it manually, even though Qt can do it better ;-) but I stand corrected, the qstrings are placed on the heap.

                If you have found the answer, please place [SOLVED] in front of your first post!

                Greetz, Jeroen

                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