How to Special Drawing ...

2468
2
06-16-2014 01:37 AM
MehmetCERAN
New Contributor
I want to draw any object from QWidget or class extending from QWidget on the EsriRuntimeQt::Graphic.How can I do that? Is there any method for this?.

That's exactly what I mean that I want to show the object based QWidget on the map. To make this I need to extend any class? if so , which is this class? or Can I specify the Symbol class? And I want to learn ,Is there any example, document or video about that? Thank for all answers..
0 Kudos
2 Replies
JeanneTrieu
Occasional Contributor
Hi,

This is currently supported however you could  paint your QWidget to a QImage and load in the image as a PictureMarkerSymbol. This would be a possible solution if you don't need to constantly update the symbol*from a QWidget.


thanks,
0 Kudos
MehmetCERAN
New Contributor
I've found a way, as follows: 🙂 Problem Solved!

customwidget = new QWidget();
customwidget ->setAttribute( Qt::WA_TranslucentBackground, true );
widgetproxy = m_mapGraphicsView->scene()->addWidget(customwidget);

connect(&m_map,SIGNAL(extentChanged()),this,SLOT(extentChangedStatus()));
connect(&m_map,SIGNAL(mouseWheel(QWheelEvent)),this,SLOT(mouseWheelStatus()));
connect(&m_map,SIGNAL(mouseMove(QMouseEvent)),this,SLOT(mouseMoveStatus()));
connect(&m_map,SIGNAL(mouseDoubleClick(QMouseEvent)),this,SLOT(mouseWheelStatus()));

////////////////////////////////////////////////////////////////////////////

void MainWindow::extentChangedStatus()
{
    if(mouseWheelTimer.isActive())
        mouseWheelTimer.stop();
    widgetproxy->setPos(m_map.toScreenPoint(point).x()-(widgetproxy->geometry().width()/2),m_map.toScreenPoint(point).y()-(widgetproxy->geometry().height()/2));

    if(widgetproxy->opacity() == 0.0)
    {
        QPropertyAnimation *animation = new QPropertyAnimation(widgetproxy, "opacity");
        animation->setDuration(200);
        animation->setStartValue(0);
        animation->setEndValue(1);
        animation->start(QAbstractAnimation::DeleteWhenStopped);
    }
}

////////////////////////////////////////////////////////////////////////////

void MainWindow::mouseWheelStatus()
{
    QPropertyAnimation *animation = new QPropertyAnimation(widgetproxy, "opacity");
    animation->setDuration(100);
    animation->setStartValue(1);
    animation->setEndValue(0);
    animation->start(QAbstractAnimation::DeleteWhenStopped);

    mouseWheelTimer.start();
}

////////////////////////////////////////////////////////////////////////////

void MainWindow::mouseMoveStatus()
{
    widgetproxy->setPos(m_map.toScreenPoint(point).x()-(widgetproxy->geometry().width()/2),m_map.toScreenPoint(point).y()-(widgetproxy->geometry().height()/2));
}

////////////////////////////////////////////////////////////////////////////

void MainWindow::mouseWheelStatus()
{
    QPropertyAnimation *animation = new QPropertyAnimation(widgetproxy, "opacity");
    animation->setDuration(100);
    animation->setStartValue(1);
    animation->setEndValue(0);
    animation->start(QAbstractAnimation::DeleteWhenStopped);

    mouseWheelTimer.start();
}
0 Kudos