The documentation says that MapView can be derived off of to create a QGraphicsWidget; however, it doesn't explain what is required to accomplish this. Besides implementing the two pure virtual functions, how might one go about implementing this?
So this is what I have done so far.
I created a class that derives off of QGraphicsWidget and MapView.
In the Paint function I call MapView::Draw.
In the resize event I resize the MapView.
I have implemented the two pure virtual functions qObjectPointer() and drawRequestedEvent. I'm not really sure what happens in drawRequestedEvent, so it's just stubbed out.
However, when the Graphics Widget is drawn all you see is a grey background.
I followed your attached example and made the changes to work with a QGraphicsWidget; however, all i see is a grey background with the esri logo on the bottom right. I don't see any tiles. Have I missed anything?
MyGraphicsObject::MyGraphicsObject(QGraphicsItem *parent)
: QGraphicsWidget(parent)
, MapView(1024,768)
{
Basemap*basemap = Basemap::streets(this);
mMap = new Map(basemap, this);
setMap(mMap);
}
void MyGraphicsObject::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QPaintEngine::Type type = painter->paintEngine()->type();
if (!painter || !painter->isActive() || (type != QPaintEngine::OpenGL2 && type != QPaintEngine::OpenGL))
return;
painter->beginNativePainting();
if (isReadyToDraw())
{
// workaround ArcGIS Runtime Qt bug which requires blending to be enabled before
// each draw request
QOpenGLFunctions* functions = QOpenGLContext::currentContext()->functions();
functions->glEnable(GL_BLEND);
draw();
}
painter->endNativePainting();
}
void MyGraphicsObject::resizeEvent(QGraphicsSceneResizeEvent * event)
{
QGraphicsWidget::resizeEvent(event);
sendGeoViewRectChangedEvent(QRectF(0,0, event->newSize().width(), event->newSize().height()));
resizeView(event->newSize().width(), event->newSize().height());
}
void MyGraphicsObject::drawRequestedEvent()
{
if(scene())
scene()->update();
}
QObject* MyGraphicsObject::qObjectPointer() const
{
return const_cast<MyGraphicsObject *>(this);
}
Hi Jon,
Are your OpenSSL libs in your path? You won't get a map to render if the application can't find those libs. Just wondering..
Eric,
Yes the openSSl libs are in the correct path. Without them there are all types of qDebug messages in the console window.
Jon