This project is read-only.

MapWinGis under Qt -> QAxBase type mismatch

Jan 22, 2015 at 11:18 AM
Dear Community,

i'm trying to get this very nice control to work. I used dumpcpp to
create the header and cpp file to use the API.
After this I tried to add the Map control to my custom Dialog via doing this:
 MapWinGis::Map *map = new MapWinGis::Map(this);
 map->SetProjection(tkMapProjection::PROJECTION_GOOGLE_MERCATOR);
 dialog->gridLayoutMap->addWidget(map);
This works fine and I can display the Map control. When I additionally add a
shapefile layer to the Map control via doing this:
wchar_t *convertedString = new wchar_t[0];
strFile.toWCharArray(convertedString);
wint_t *temp = reinterpret_cast<wint_t*>(convertedString);
map->AddLayerFromFilename(temp, tkFileOpenStrategy::fosAutoDetect, true);
I get the following error message:
QAxBase: Error calling IDispatch member AddLayerFromFilename: Type mismatch in parameter 0 (qaxbase.cpp:3502, bool checkHRESULT(LONG, EXCEPINFO*, QAxBase*, const QString&, uint))
The following link had this problem as topic but it didn't lead into a solution.
Probably somebody has solved this issue yet:
Discussion Link

I successfully registered the MapWinGis.oxc by exscuting RegSvr32.

Any ideas?

Thanks and regards
Nils
Jan 24, 2015 at 9:03 AM
Edited Jan 24, 2015 at 9:04 AM
Hi Nils,

I have no experience with QT, but here are some thoughts. Filename parameter of Map.AddLayerFromFilename is defined as LPCTSTR. Since we are not using Unicode build it's compiled into LPCSTR (const char*). So I'm not particularly surprised that there are problems when you are trying to pass wide string.

It's also possible to open layers using classes like Shapefile and OgrLayer directly (e.g. Shapefile.Open). Please check this doc for the details. These classes use dual interfaces rather than just IDispatch and string parameters are passed as BSTR which are Unicode and it seems are available in QT.

Hope this helps,
Sergei