Graphics View graphics architecture (II)

Graphics View major class structure comprising: view class QGraphicsView, scene classes QGraphicsScene, and various graphical item class (classes are QGraphicsItem yl)

1. QGraphicsView physical window for viewing a scene

  View the scene is less than the entire scene visible in the view; view when a scene is greater than an attempt to automatically provide volumes of the roller

  QGraphicsView viewport coordinates equal to the coordinates of the physical display device, but may be a translation of coordinates QGraphicsView, rotation and scaling

  Interface function is provided as follows:

 

 

Scenes void     setScene()  // set the scene associated
  void  setSceneRect()   // scene visible in the view area of ​​the rectangular portion
     
Exterior setAlignment void ()  // set the alignment of the scene in view
  void     setBackgroundBrush()  
  void     setForegroundBrush()  
  void      setRenderHints( ) // Set drawing options
     
Alternately void setInteractive() Interactive
  QRect rubberBandRect Back to selection rectangle
  void setRubberBandSelectionMode() Selection Mode
  QGraphicsItem *itemAt() Get the view coordinate system at a location graphical items
  QList<QGraphicsItem *> items() Get a list of all or a selected area of ​​the graphic item in the scene
coordinate QPoint        mapFormScene Converting a coordinate of a view of the scene coordinates
Mapping QPointF      mapToScene The coordinate conversion view a scene coordinates

 

2 QGraphicsScene mainly used for scene management graphic item, the item is a container for graphics, there are add, delete function, a variety of management functions of graphical items graphic item.

Scenes void setSceneRect() A scene set rectangular region
Packet QGraphicsItemGroup* createItemGroup() Create a graphic item groups
  void destroyItemGroup() Group released a graphic item
Input focus QGraphicsItem * focusItem Returns the current graphic item has focus
  void clearFocus Remove the selection focus
  bool hasFocus Whether it has the focus when the view is
Graphic term operation void addItem() Adding a graphical items that have been created
  void removeItem() Delete graphic item
  void clear() Clear all graphical items
 

QGraphicesItem* mouseGrabberItem()

Returns the graphical items mouse crawl
  QList<QGraphicsITEM *>selectedItems() Returns a list of graphical items selected
  QGraphicsItem *itemAt() Get top-level graphical item at a certain location
  QList<QGraphicsITEM *> items() Returns a list of items in the selected area pattern
     
     

 

3 QGraphicsItem pattern is the base class for all classes

Note coordinate mapping

Guess you like

Origin www.cnblogs.com/AmyBKLP/p/11706412.html