How to convert QList to Array of C++
-
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.
-
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.
-
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.
-
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.
-
To pass it to an external library, to old-not-easy-to-modify code, or just to check he's good at avoiding crashs !
-
Hi, i want use standard C++ because my application run on multiple platform( win and mac os)
Thank you for your answers. -
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 -
[SOLVED]
Thank you. This topic closed.