How to use qgraphicsscene
This article mainly shows you "how to use qgraphicsscene", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use qgraphicsscene" this article.
This QGraphicsScene class is used to manipulate a large number of 2D graphic elements in the scene, this class exists as a container QGraphicsItems, it is together with QGraphicsView for visualization of two-dimensional surface graphics items, such as lines, rectangles, text, and even custom objects; it can also effectively determine the location of elements in the scene and control the display area and way of elements. With QGraphicsView you can visualize the whole scene, or zoom out or show only part of the scene.
What is qgraphicsscene?
First of all, let's change the name QGraphicsView,QGraphicsScene:
QGraphicsScene is called a graphical scene.
QGraphicsView is called the graphics window.
You can understand that the QGraphicsScene graphics window is a visual interface, just like the shell of a TV, and the QGraphicsScene graphics scene is the screen of the TV. The content to be played is to be displayed on the screen.
Note: the QGraphicsScene graphics window has its own non-visual appearance, which only manages projects. You need to create a QGraphicsView graphical view to load the widget to visualize the scene.
Qgraphicsscene example
_ _ author__='liaojie'
#! / usr/bin/envpython
# coding:utf-8
FromPyQt5.QtWidgetsimport (QGraphicsView,QGraphicsScene,QApplication)
If__name__=='__main__':
Importsys
# each PyQt program must create an application object, and the sys.argv parameter is a set of parameters on the command line
# Note: application is in the PyQt5.QtWidgets module
# Note: application is in the PyQt4.QtGui module
App=QApplication (sys.argv)
# create a scene
Scene=QGraphicsScene ()
# add text to the scene
Scene.addText ("Hello,world!")
# create a window and load the scene into the window
View=QGraphicsView (
# display application
View.show ()
The above is all the contents of this article "how to use qgraphicsscene". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!