C++ (Qt)virtual void mousePressEvent ( QMouseEvent * event )virtual void mouseMoveEvent ( QMouseEvent * event )virtual void mouseReleaseEvent ( QMouseEvent * event )
virtual void mousePressEvent ( QMouseEvent * event )virtual void mouseMoveEvent ( QMouseEvent * event )virtual void mouseReleaseEvent ( QMouseEvent * event )
void sch_symbol_editor::mousePressEvent(QMouseEvent * event){ if (event->button() == Qt::RightButton) { m_dragging_ref_point.rx() = event->x(); m_dragging_ref_point.ry() = event->y(); QScrollBar* hBar = horizontalScrollBar(); QScrollBar* vBar = verticalScrollBar(); m_dragging_scroll_ref_point.rx() = hBar->value(); m_dragging_scroll_ref_point.ry() = vBar->value(); right_button_pressed = true; }}
void sch_symbol_editor::mouseReleaseEvent ( QMouseEvent * event ){ if (event->button() == Qt::RightButton) right_button_pressed = false;}
void sch_symbol_editor::mouseMoveEvent ( QMouseEvent * event ){ // если нажата правая кнопка мыши то смещаем вид за мышкой if (right_button_pressed) { QPoint p; p.rx() = event->x(); p.ry() = event->y(); QScrollBar* hBar = horizontalScrollBar(); QScrollBar* vBar = verticalScrollBar(); hBar->setValue(m_dragging_ref_point.x() - event->x() + m_dragging_scroll_ref_point.x() ); vBar->setValue(m_dragging_ref_point.y() - event->y() + m_dragging_scroll_ref_point.y() ); } else // если нет то вызываем обработчик по умолчанию QGraphicsView::mouseMoveEvent(event);}