Examples of QPointF


Examples of com.trolltech.qt.core.QPointF

    super.mouseMoveEvent(event);
  }

  public void wheelEvent(QWheelEvent event) {
    // Get the position of the mouse before scaling, in scene coords
    QPointF pointBeforeScale = mapToScene(event.pos());

    // Scale the view ie. do the zoom
    double zoom = this.matrix().m11();
    if (event.delta() > 0) {
      // Zoom in (if not at limit)
      if(zoom < zoomMax)
        scale(scaleFactor, scaleFactor);
    } else {
      // Zoom out (if not at limit)
      if(zoom > zoomMin)
        scale(1.0 / scaleFactor, 1.0 / scaleFactor);
    }

    // Get the position after scaling, in scene coords
    QPointF pointAfterScale = mapToScene(event.pos());

    // Get the offset of how the screen moved
    QPointF offset = new QPointF(
        pointBeforeScale.x() - pointAfterScale.x(), pointBeforeScale
            .y()
            - pointAfterScale.y());
    this.horizontalScrollBar().setValue((int) (this.horizontalScrollBar().value()+zoom*offset.x()));
    this.verticalScrollBar().setValue((int) (this.verticalScrollBar().value()+zoom*offset.y()));
  }
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.