qt中调用mapx地图时,出现QAxBase::qt_metacall: Object is not initialized, or initializatio
白日_焰火 2019-03-15 03:54:18 在Qt里调用mapx控件,想绘制圆形的区域,但是在运行时异常结束。应用程序输出 显示
QAxBase: Error calling IDispatch member GeoSet: Exception thrown by server
Code : 1011
Source : MAPX50
Description: ??: ????????????????????
Help : C:\PROGRA~2\MapInfo\MAPX5~1.0\MAPX50.HLP [400011]
Connect to the exception(int,QString,QString,QString) signal to catch this exception
before : 55
after : 56
QAxBase::qt_metacall: Object is not initialized, or initialization failed
D:\sogou_pinyin\SogouInput\Components\----------------------------------------------
程序异常结束。
调试时,发现程序中断在如下代码中的 qt_metacall(QMetaObject::InvokeMetaMethod, 9, _a);
inline void CMapXPoint::Set(double X, double Y)
{
void *_a[] = {0, (void*)&X, (void*)&Y};
qt_metacall(QMetaObject::InvokeMetaMethod, 9, _a);
}
整个函数的代码如下:
CMapXPoint *pt;
CMapXFeature *drawCircular;
CMapXLayers *layers;
CMapXLayer *layer;
CMapXStyle *style;
pCMapFeaFactory = map->FeatureFactory();
layers = map->Layers();
qDebug()<<"before : "<<map->Layers()->Count();
bool flag = false;
for(int i=1;i<=layers->Count();i++){
layer = layers->Item(i);
if(layer->Name() == "DetectionRange"){
flag = true;
break;
}
}
if(flag == false){
CMapXLayer *lyr = map->Layers()->CreateLayer("DetectionRange");
map->Layers()->SetAnimationLayer(lyr);
}
layer = map->Layers()->Item("DetectionRange");
qDebug()<<"after : "<<map->Layers()->Count();
pt = drawCircular->Point();
pt->Set(104.65,31.5124);
style->SetRegionBackColor(FillPatternConstants::miPatternNoFill);
style->SetRegionBorderColor(ColorConstants::miColorRed);
style->SetRegionBorderStyle(PenStyleConstants::miPenSolid);
style->SetRegionBorderWidth(2);
style->SetRegionPattern(FillPatternConstants::miPatternNoFill);
double v = 10.0;
int vv = 1024;
drawCircular = pCMapFeaFactory->CreateCircularRegion(CircleTypeConstants::miCircleTypeScreen,
pt->asVariant().value<IDispatch*>(),10,
v,vv,style->asVariant());
layer->AddFeature(drawCircular->asVariant().value<IDispatch*>());
layer->Refresh();