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. How to convert QList to Array of C++
Forum Updated to NodeBB v4.3 + New Features

How to convert QList to Array of C++

Scheduled Pinned Locked Moved General and Desktop
8 Posts 5 Posters 11.1k 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.
  • P Offline
    P Offline
    phamvanan
    wrote on 12 Jul 2013, 07:25 last edited by
    #1

    Hi guys,
    Please tell me a way convert from QList to Array in Qt 4.8
    @ QList<InstallFont*> _fileInstallFontList;@

    convert to :
    @InstallFont** inInstallFontArray;@

    Thanks in advance.

    -PVA-

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on 12 Jul 2013, 07:41 last edited by
      #2

      Convert the QList to QVector, then ,you get can the data pointer from it.

      Or you can create a array of your data type, then copy all the data to it.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Adrien Leravat
        wrote on 12 Jul 2013, 07:48 last edited by
        #3

        Agreed, and to add a little explanation: QList doesn't store its data as contiguous elements in memory (which is the case of QVector/std::vector), that's why there is no direct conversion available.

        Adeneo Embedded - www.adeneo-embedded.com

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Peppy
          wrote on 12 Jul 2013, 08:19 last edited by
          #4

          Well you can do that but I don't see the reason why to do so. It is more safety to use QList than a raw array.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Adrien Leravat
            wrote on 12 Jul 2013, 08:22 last edited by
            #5

            To pass it to an external library, to old-not-easy-to-modify code, or just to check he's good at avoiding crashs !

            Adeneo Embedded - www.adeneo-embedded.com

            1 Reply Last reply
            0
            • P Offline
              P Offline
              phamvanan
              wrote on 12 Jul 2013, 08:25 last edited by
              #6

              Hi, i want use standard C++ because my application run on multiple platform( win and mac os)
              Thank you for your answers.

              -PVA-

              1 Reply Last reply
              0
              • J Offline
                J Offline
                Jeroentjehome
                wrote on 12 Jul 2013, 09:30 last edited by
                #7

                Hmm, Qt is cross-platform.........that's the strength of Qt! If done properly in Qt you are able to compile your code on any platform supported without resorting to C++ standard code.
                Btw if you feel the topic has been answered post [SOLVED] in front of your first post

                Greetz, Jeroen

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  phamvanan
                  wrote on 12 Jul 2013, 09:39 last edited by
                  #8

                  [SOLVED]
                  Thank you. This topic closed.

                  -PVA-

                  1 Reply Last reply
                  0

                  1/8

                  12 Jul 2013, 07:25

                  • Login

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