Can't store a QPointer into a QVariant
I'm trying to store a Pointer to a QVector<Album*> into a QAction, but I can't convert it to QVariant.
and it fails with following error:
In instantiation of 'QPointer<T>::QPointer(T*) [with T = QVectorDigikam::Album*]':
/media/LinuxHDD/slavik/digikam-software-compilation/core/digikam/tags/tagmodificationhelper.cpp:98:72: required from here
/usr/include/qt4/QtCore/qpointer.h:59:32: error: cannot convert 'QVectorDigikam::Album*' to 'QObject' in initialization
inline QPointer(T *p) : o(p)
I don't know how to deal with this... QPointer<QVector> works fine , but QPointer<QVector<Album*> > won't...
QPointer must be used with QObject, have a look at "this":http://qt-project.org/doc/qt-4.8/qpointer.html#details
But, QVector is a QObject, I only added a template argument to it...
I can't use QPointer<QVector>(data) because of template mismatch.
No, QVector is not a QObject, it's a templated container (you can verify in the source code).
QVector does not subclass QObject, so it is not a QObject.
So a container won't work...
Any idea of how to pass that pointer through QAction?
You can use quintptr but are you sure that having that in the action is the best design ?
I was able to pass it with:
Basically, I try to implement item deletion in a context menu. Originally, tree was single selection and a pointer to item was encoded into QAction's data. Now, I'm trying to implement multiple selection and deletion is the first one to change...
The design of KDE's digiKam is complicated and I can't have direct access to treeView to ask for selected items. Instead, I should stick to this design, but I accept all suggestions :)