Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ QVariant到QPainterPath的转换_C++_Qt_Qvariant - Fatal编程技术网

C++ QVariant到QPainterPath的转换

C++ QVariant到QPainterPath的转换,c++,qt,qvariant,C++,Qt,Qvariant,我现在制作的迷你游戏有问题。问题如下:我已经为我的游戏创建了一个关卡编辑器,因此我必须创建自己的代理和模型,当我试图通过shapeeditor(更可能创建一个painterpath)进行编辑时,就会出现问题。然后通过数据返回painterpath,但当我尝试使用委托绘制它时,qt告诉我以下错误: /usr/include/qt4/QtCore/qmetatype.h:169: error: 'qt_metatype_id' is not a member of 'QMetaTypeId<Q

我现在制作的迷你游戏有问题。问题如下:我已经为我的游戏创建了一个关卡编辑器,因此我必须创建自己的代理和模型,当我试图通过shapeeditor(更可能创建一个painterpath)进行编辑时,就会出现问题。然后通过数据返回painterpath,但当我尝试使用委托绘制它时,qt告诉我以下错误:

/usr/include/qt4/QtCore/qmetatype.h:169: error: 'qt_metatype_id' is not a member of 'QMetaTypeId<QPainterPath>'
/usr/include/qt4/QtCore/qmetatype.h:169:错误:“qt\u metatype\u id”不是“QMetaTypeId”的成员
我不太清楚我为什么会有这个错误。有关项目源代码的信息,如果需要,我可以提供。但我只是认为从qvariant到qpainterpath的转换是不可能的。他们一定是这样做的

注意:我试着做了以下几点

QVariant var = index.model()->data(index, Qt::DecorationRole);
QPainterPath path = var.value<QPainterPath>(); // The error occurs here, this is line 169
QVariant var=index.model()->数据(index,Qt::DecorationRole);
QPainterPath路径=变量值();//错误发生在这里,这是第169行
但是这没用><如果你能帮我,谢谢
可能的解决方案是,是否仍然可以从painterpath创建一个pixmap?我可以简单地返回pixmap而不是painterpath。

看起来您需要在QPainterPath中使用Q_DECLARE_元类型宏


文档是否相同。

是否先将QPainterPath声明为元类型?看见
Q_DECLARE_METATYPE (QPainterPath)