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(); }
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.