在场景中,我通过对象接口类放置对象并创建对象(不同类型的对象,如刻度盘,绘图仪,温度计)。我必须通过对象接口类更改对象的属性。但是当场景中选择一个对象时,如何找出对象的接口类指针呢?欢迎任何想法...
#include "ObjectInterfaceClass"
if(event->mimeData()->text() == "Plot")
{
ObjInterfaceClass * pObjInterface = new ObjInterfaceClass ;
const QMimeData *mime = event->mimeData();
QByteArray itemData = mime->data(itemlistMimeType());
QDataStream dataStream(&itemData, QIODevice::ReadOnly);
QVariant width ,height ;
dataStream >> width >> height ;
pObjInterface->mObjProperety.geometry.height = height.toInt() ;
pObjInterface->mObjProperety.geometry.width = width.toInt() ;
pObjInterface->mObjProperety.geometry.xPos = event->pos().x() ;
pObjInterface->mObjProperety.geometry.yPos = event->pos().y() ;
pObjInterface->SetGraphicsScene((void*)scene);
pObjInterface->CreateObject(CUSTOM_PLOT_NAME) ;
pObjInterface->DrawObject();
}
有关更多详细信息image of objects dropped on scene 或如何为对象分配对象接口指针?