This chapter describes the features, elements, and coordinate systems of the graphics view framework.
1. Features of graphics view framework structure:
(1) The system can use the Qt graphics system's anti-sawtooth and OpenGL tools to improve the Drawing performance.
(2) it supports the event propagation structure, which doubles the interaction capability of elements in the scenario, and the flange can handle keyboard and mouse events.
(3) BSP provides quick metadata search to display large scenarios with millions of elements in real time.
2. Three elements of graphics View:
(1) scenario class (qgraphicsscene): it is invisible. It is a container for storing elements that must be displayed through the Connected View class and operated with the outside world. You can use qgraphicsscene: additem () to add elements.
Qgraphicsscene: items () and some heavy-duty functions can return all elements that intersect with points, rectangles, polygon, or vector paths.
Qgraphicsscene: itemat () returns the top-level element of the specified vertex.
Qgraphicsscene: setselectedareas () function selects elements. The selected area can be in any shape, expressed by qpainterpath.
Qgraphicsscene: selecteditems () function to obtain the list of currently selected elements.
Qgraphicsscene: setfocusitem () function or qgraphicsscene: setfocus () function to set the focal point of an element.
Qgraphicsscene: focusitem () function to obtain the elements with the current focus.
Qgraphicsscene: The Reader () function draws a scenario on the drawing device.
(2) View class (qgraphicsview): provides a visual window for displaying elements in a scenario. It is a tumble window part and provides a scroll bar to browse large scenes.
Qgraphicsview: setviewport: Set the view to qglwidget.
Qgraphicsview: matrix () can be used to convert the coordinates of a scenario to achieve scene scaling and rotation.
Qgraphicsview: maptoscene () and qgraphicsview: mapfromscene () are used to convert scene coordinates.
(3) element class (qgraphicsitem): it is the base class of each element in the scenario. Based on this class, it can inherit various element classes,
Including qgraphicslineitem, qgraphicsellipseitem, qgraphicstextitem, and qgraphicsrectitem.
3. Coordinate System of qgraphicsview:
Based on the Cartesian Product coordinate system, an element scenario has X and Y coordinates.
(1) scene coordinate: it is the basic Coordinate System of all elements.
(2) view coordinates: Coordinates of window components. The unit of View coordinates is pixel.
(3) metacoordinate: the primitive uses its own local coordinate. This coordinate system usually uses the center of an element as the origin, which is also the origin of all transformations.
Concept of qt5 graphic view framework (1)