qlist

Saving QList<T> to a file?

I've got a QList of QLineEdit*'s QList<QLineEdit*> example; Example will hold 100 items of lineEdits. When I try to save or load to a file, it fails to save or load the QList properly, if at all. I get a much lower than expected count of data. I see on QList<T>'s resource page here that there's the correct operator for << & >>, ho...

Inheriting from a container with non-virtual destructor

I'm trying to use forward declarations and d-pointers to eliminate some include dependencies. Everything is working well, except that I have used XList typedefs for readability in many places (e.g: typedef QList<X> XList). The workaround for the typedef forward declaration issue is to use inheritance: class XList : public QList<X>{};. ...

Pointer to QList - at() vs. [] operator

I'm having problem with understanding some of QList behavior. #include <QList> #include <iostream> using namespace std; int main() { QList<double> *myList; myList = new QList<double>; double myNumber; double ABC; for (int i=0; i<1000000; i++) { myNumber = i; myList->append(myNumber); AB...

dynamic memory in QList

I don't have much experience with QT and this problem came out today. QList<int> memList; const int large = 100000; getchar(); for (int i=0; i<large; i++) { memList.append(i); } cout << memList.size() << endl; getchar(); for (int i=0; i<large; i++) { memList.removeLast(); } cout << memList.size() << endl; getchar(); After ...

QList memory deallocation

I'm trying to free memory after using QList, but it doesn't seem to work properly. Here's my code: QList<double> * myList; myList = new QList<double>; double myNumber; cout << "CP1" << endl; getchar(); // checkpoint 1 for (int i=0; i<1000000; i++) { myNumber = i; myList->append(myNumber); cout << myList->size() << endl; ...

Element is removed from QList but static counter of existing objects doesn't decrease

I have question about removing element from QList. "myclass.h": class node2D : public QObject { Q_OBJECT public: node2D(){++s_NCount;}; ~node2D(){--s_NCount;}; int checkCount(){return s_NCount;}; private: static int s_NCount; }; "myclass.cpp": int node2D::s_NCount = 0; "main.cpp": void main() { int i,ma...

Save QList<int> to QSettings

Hello, I want to save a QList<int> to my QSettings without looping through it. I know that I could use writeArray() and a loop to save all items or to write the QList to a QByteArray and save this but then it is not human readable in my INI file.. Currently I am using the following to transform my QList<int> to QList<QVariant>: QL...

how to send QList<Object *> objects to another class ?

hi i'm trying to send a QList as a parameter to another class but for some reason i lose all it's content ... (when i open the object with the debuger i see for objects...) trying to send QList books to class Print: class Store: public QWidget { Q_OBJECT public: Analyze(QWidget *parent = 0); void generate_report(); ~An...

App crashes when QList grows too large

Hi. I make an application which has to store a lot of data in memory to improve calculation performance. It is a hierarchy of lists and objects where the top object is a QList<myObject*>. When loading data, a lot of instances of new myObject* are created and added to the list. The memory consumption grows and when it comes to ~1.9Gb the...

Appending pointers to QList

I need to insert pointers of classes (inherited from QObject) into a QList. I know that the following syntax can be used: .h QList<MyObject*> list; .cpp list.append(new MyObject("first", 1)); list.append(new MyObject("second", 2)); ... and then free memory: if(!list.isEmpty()) { qDeleteAll(list); list.clear(); } This sh...

C++ QList inheritance custom method problem

Hi, i am new to C++ I am creating a custom QList of type Account* called AccountList through inheritance. My interface declaration for AccountList is as follows: class Client { public: Client(QString firstName, QString lastName, QString address1, QString address2, QString postalCode); QString toString(); priva...