QVariant conversion to QPainterPath

311 views Asked by At

I have a problem right now with my mini-game I am making. The problem is as follows: I have created an level editor for my game and thus I had to create my own delegate and model, the problem occurs when I try to edit through a shapeeditor ( which more likely creates a painterpath ). I then return the painterpath through data but when I try to paint it with my delegate, qt tells me the following error:

/usr/include/qt4/QtCore/qmetatype.h:169: error: 'qt_metatype_id' is not a member of 'QMetaTypeId<QPainterPath>'

I am not quite sure why I am having this error. For information regarding the source code of the project, I can give if needed. But I am simply thinking the conversion from qvariant to qpainterpath isn't possible. They must be a way to do it.

Note: I tried to do the following

QVariant var = index.model()->data(index, Qt::DecorationRole);
QPainterPath path = var.value<QPainterPath>(); // The error occurs here, this is line 169

But this didn't work >.< Thanks if you can help me Possible solution, is there anyway to create a pixmap from the painterpath? I could simply return the pixmap instead of the painterpath.

1

There are 1 answers

0
Kunal On

Looks like you need to use Q_DECLARE_METATYPE macro with QPainterPath

Like

Q_DECLARE_METATYPE (QPainterPath)

Here is documentation for the same.