Right way to hold and manage a lot of data
RegineerCZ last edited by
I'm here to ask for advice in my development.
What im trying to make is an app that will connect to device (BLE device) and will send message to it and receive response from it. This device is actually a bridge between a communication for luminaires and my application.
I need a way of holding all data from these luminaires, setting these data and if they change, producing signals (individual for each device and each value) which will connect to slots of widget on screen. So in example if user is looking at screen with like, actual level of certain luminaire, and this value changes, i need to change it on screen as well.
What i did is i created my own object called DaliDevice. This object inherits from QObject, and it holds all data, it has functions for each of these data to be set (which sends an emit valueXYZChanged() signal.
Then i created a QList<DaliDevice> * deviceList inside my Communication object. Which handles connection and sending and receiving data for me, also inherits from QObject.
I also created a pointer to this object inside my window header file, Communication * communicationHandler
What i tried then is to call a function inside one of these DaliDevices. I did following:
DaliDevice device = communicationHandler->deviceList.at(0);
I got error on deviceList.at(0), saying "use of deleted function DaliDevice::DaliDevice(const DaliDevice&)"
Does anybody here knows better way of doing such a communication? Or what is the problem with my code?
Maybe you should try to hold a pointer to DaliDevice in your QList.
Or implement a copy constructor for DaliDevice... ;-)
Hi and welcome to devnet,
@ttuna: bad idea, QObject are not http://doc.qt.io/qt-5/qobject.html#no-copy-constructor-or-assignment-operator
But the first solution is correct: use a QList<DaliDevice*> or QVector<DaliDevice *>. Note that you don't need to allocate deviceList on the heap.
@SGaist Maybe you missed the little smiley on this hint ... ;-)
No I didn't, but I can assure you that written second degree doesn't work as well as spoken ;-)
And I've already saw code implementing them… So I avoid the risk of misguiding people
Sorry, my fault ... I will hold back this inner ironic imp in the future.