[SOLVED] Monitoring an object changed asynchronously by a Callback function
-
Hi,
If you need that much performance, you'd better do a benchmark. What is your use case ?
-
Why not embed that QVector in a QObject wrapper that will emit a signal whenever the vector is modified ?
-
@SGaist said:
Why not embed that QVector in a QObject wrapper that will emit a signal whenever the vector is modified ?
QVector in a QObject wrapper?
I thought about something like:
QBuffer buffer(&byteArray);
and then use the above mentioned QBuffer signals.
-
That's also an alternative yes, you can even go further using a QIODevice derived class and create a device that would your data directly
-
Yes, I subclassed QBuffer, implemented my own
qint64 MyBuffer::writeData(const char *data, qint64 len) { buffer().clear(); buffer().append(data,len); emit bytesWritten(len); return len; }
and then:
QObject::connect(DDEComm::instance()->buf,&QBuffer::bytesWritten,[=](qint64 bytes) { printf("bytesWritten: %d, Buffer: %s\n", (int) bytes, DDEComm::instance()->buf->data().data()); });
It works so far as it should.
But what was your proposal about embedding QVector in a QObject wrapper?
Is is something where one has to use http://doc.qt.io/qt-5/properties.html ?Anyway I'd mark then this thread as SOLVED.
-
No you don't have to. The use of properties depends on your software architecture and your class design.