当前位置:网站首页>pyqt5 pyside2
pyqt5 pyside2
2022-06-09 09:33:00 【why151】
Direct import ui
from PySide2.QtUiTools import QUiLoader
import sys
from PyQt5.QtWidgets import QApplication
ui_file = QFile("test.ui")
ui_file.open(QFile.ReadOnly)
app = QApplication(sys.argv)
loader = QUiLoader()
window = loader.load(ui_file)
window.show()
sys.exit(app.exec_())
Show interactive pictures
from PySide2.QtGui import QImage, QPixmap
from PySide2.QtUiTools import QUiLoader
from PyQt5.QtWidgets import QApplication, QGraphicsView
from PySide2.QtWidgets import QGraphicsScene, QGraphicsPixmapItem
import sys
import cv2 as cv
app = QApplication(sys.argv)
map = QUiLoader().load('test.ui')
''' Start introducing pictures to create scenes '''
pix = QPixmap('school.jpg')
# Create pixel primitives
item = QGraphicsPixmapItem(pix)
scene = QGraphicsScene()
scene.addItem(item)
map.show_school.setScene(scene)
map.show()
sys.exit(app.exec_())
Obtain the coordinates of image points and mark them in the image
Mainly want to change the mouse cursor style , After selecting a point, the mouse cursor style is restored and the position of the point is returned .
I have searched the Internet for a long time , Most of the posts you see are about rewriting classes , However, I don't know how to cook , Finally, I found the implementation method .
# Set up scene
pix = QPixmap('school.jpg')
self.item = QGraphicsPixmapItem(pix)
self.scene = QGraphicsScene()
self.scene.addItem(self.item)
self.img.show_school.setScene(self.scene)
def find_begin(self):
# Set the mouse cursor style
pix_begin = QPixmap('start.png')
pix_begin = pix_begin.scaled(60, 60, QtCore.Qt.KeepAspectRatio)
# Set the focus position of the mouse cursor
cursor = QCursor(pix_begin, 30, 59)
self.img.show_school.setCursor(cursor)
# Set mouse click events
self.item.mousePressEvent = self.get_start
if self.if_find_start != -1:
self.scene.removeItem(self.pix_begin)
self.if_find_start = 1
def get_start(self, event):
if self.if_find_start == 1:
self.if_find_start = 0
pos = event.pos()
self.start = (Node) (int(pos.x()//25), int(pos.y()//25), 0, 0, None)
pix_begin = QPixmap('start.png')
pix_begin = pix_begin.scaled(60, 60, QtCore.Qt.KeepAspectRatio)
self.pix_begin = QGraphicsPixmapItem(pix_begin)
self.pix_begin.setPos(pos.x()-30, pos.y()-59)
self.scene.addItem(self.pix_begin)
# Restore the mouse cursor to the original arrow cursor
self.img.show_school.setCursor(Qt.ArrowCursor)
Nice style
There are two that can be referenced python Style sheets in the library
Click to see
One more dalao Handwritten super nice pages
Click to see
边栏推荐
- Reroute the final chapter of riverpod in the state management of flutter
- MySQL basic subquery exercise
- MySQL basic database creation foundation
- neo4j实现社交推荐(四)
- 2022-2028 global technology monitoring countermeasures industry research and trend analysis report
- Implementation of WTM based on NETCORE framework
- 判断是Json还是文件流
- 了解图数据库neo4j(二)
- [redis learning 11] data persistence of distributed cache, master-slave cluster
- Will testing not be replaced by development?
猜你喜欢

MySQL基础 多表查询

three.js学习笔记(十五)——着色器图案
![[code comment] Doxygen](/img/db/0017e30ef8ff5d9d71a9d02a7ed7cf.png)
[code comment] Doxygen

How to draw a picture gracefully

Summary of Android development interview experience and compilation of actual records (must see)

Learn about graph database neo4j (I)

C language pointer

What's wrong with Android development today? Is the interview question I asked so difficult?

three. JS learning notes (16) -- turbulent ocean

Kusionstack has a sense of open source | it took two years to break the dilemma of "separating lines like mountains"
随机推荐
MySQL basic addition, deletion, modification and query exercise
Android common principle interview questions (preliminary sorting)~
2022-2028 global UAV detection and jamming system industry survey and trend analysis report
2022-2028 global online programming learning platform industry survey and trend analysis report
Opencv获取图像像素值数据类型
GLCC's first programming summer camp welcome to sign up for layotto, kusionstack, Nydus, Kata containers!
Omit application reduces TS duplicate codes
了解图数据库neo4j(二)
Crop the target area in the image according to the projection coordinates (with complete code)
论文理解【RL - Exp Replay】—— An Equivalence between Loss Functions and Non-Uniform Sampling in Exp Replay
Countdown 3 days 𞓜 sofachannel 28 sofaark class isolation framework design
Write InputStream to file write multipartfile to file
2022-2028 global natural volcanic ash industry research and trend analysis report
MySQL基础 多表查询
Understand the graph database neo4j (III)
Annexe 17 interprétation du programme réseau
[matlab] [digital simulation] [1] linprog solving linear programming, standard type
Document sorting (expansion)
初级指针~带你入门指针
Reroute the final chapter of riverpod in the state management of flutter