Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Dynamic or stack
Lisun last edited by
Could anyone explane how classes works in Qt.
Or maybe its a deeper question - related to how C++ work))
1.For example i have big txt file (e.g. a.txt) . In my function (e.g foo) i create QFile to work with a.txt.
if i create it in static way ( QFile a("a.txt")) is it mean all data in a.txt may be putted to stack sometime. I mean , does QFile bufferring data it works with (maybe in some of its functions) or QFile is just functions which operate with memory already reserved by file.
2. When function returns value (for example QStringList QDir::entryList) where it store this value before returning. I see QStringList returns by value (not a pointer), but if list is a huge list...will it be sent throught stack?
Will it be better organaize code of function (when big size of data in list is expected) in sach way:
QDir *direct = new QDir(dir);
QStringList fl =new QStringList(direct->entryList());
QStringList *fl =new QStringList(direct->entryList());
Where to read about how it works?
QFile a("a.txt")) is it mean all data in a.txt may be putted to stack sometime
No, QFile does not buffer the whole file.
"but if list is a huge list...will it be sent through stack?" - Qt containers use implicit sharing (see https://doc.qt.io/qt-5/implicit-sharing.html), so no it will not copy a huge list as long as you do not modify it.
"Where to read about how it works?" - in a C++ book.