2

I have a QVector containing 8 integers. Now I would like to have a signal that is emitted when a element of this vector is changed. This signal should contain the number of the element that is changed.

How would I do this?

2 Answers 2

3

QVector is not derived from QObject, so no signals are emitted.

What you can do is encapsulate a QVector object as a private member in your own class that is derived from QObject and code the modification methods you need and also code and emit signals you need in that class.

3

That's rather tricky. You should not inherit from QVector as it doesn't have a virtual destructor and there are no protected functions which you can use to hook into. The safest way is to wrap a QVector into your own domain-specific class that implements those signals.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.