当前位置:网站首页>Qmenu response in pyqt
Qmenu response in pyqt
2022-06-24 08:26:00 【Qredsun】
Demand scenarios :
stay qt In the interface , You need to add a response action to the menu .
Realization :
Look at the QMenu Object source code , Nothing like QPushButton.clicked() Signal function of . Only found QMenu.triggered() function , Already used QMenu.addAction(). That is to say , Only through triggered Trigger menu list , Add... To the menu list QAction(), Use QAction() Associate the corresponding slot function , Implement operational response .
Concrete realization :
- qt The control association in the interface :
# UI relation
menuBar = QtWidgets.QMenuBar() # menu bar
menuBar.setGeometry(QtCore.QRect(0, 0, 1245, 23))
menuBar.setObjectName("menuBar")
menu = QtWidgets.QMenu() # Menu buttons
menu.setObjectName("menu")
menu_check = QtWidgets.QMenu(menuBar)
menu_check.setObjectName("menu_check")
actionSavePicture = QtWidgets.QAction() # Action response , Modify the storage path
actionSavePicture.setObjectName("actionSavePicture")
menu.addAction(actionSavePicture) # Menu button add action
- The signal slot Association in the back-end response code
actionSavePicture.triggered.connect(changeImgSavePath)
def changeImgSavePath():
# Get directory path
save_path = QFileDialog.getExistingDirectory(None, caption=' Select the screenshot storage directory ')
if save_path:
img_save_path = save_path
cam_conf = CameraConfig()
cam_conf.img_save_path = save_path
cam_conf._update_cfg_file()
QMessageBox.about(None, ' Tips ', f' The screenshot storage directory is changed to :{
save_path}')
else:
QMessageBox.about(None, ' Tips ', ' The screenshot storage directory has not been changed ')
边栏推荐
- About the iframe anchor, the anchor is offset up and down, and the anchor has page display problems Srcdoc problem of iframe
- Scénarios d'utilisation de la promesse
- Understanding of the concept of "quality"
- Transformers pretrainedtokenizer class
- Introduction to software engineering - Chapter 3 - Requirements Analysis
- 5分钟,客服聊天处理技巧,炉火纯青
- 2021-03-11 comp9021 class 8 notes
- 2021-03-16 comp9021 class 9 notes
- 2022 mobile crane driver special operation certificate examination question bank and online simulation examination
- Solution of electric education system for intelligent supervision station
猜你喜欢

How to use the virtual clock of FPGA?

jwt(json web token)

2022茶艺师(中级)上岗证题库及在线模拟考试

Question 4 - datepicker date selector, disabling two date selectors (start and end dates)

小样本故障诊断 - 注意力机制代码 - BiGRU代码解析实现

2022年流动式起重机司机特种作业证考试题库及在线模拟考试

C语言_字符串与指针的爱恨情仇

io模型初探

Opencv实现图像的基本变换

Pagoda panel installation php7.2 installation phalcon3.3.2
随机推荐
Chart list Performance Optimization: minimum resource consumption in the visualization area
贷款五级分类
os.path.join()使用过程中遇到的坑
问题4 — DatePicker日期选择器,2个日期选择器(开始、结束日期)的禁用
Question 4 - datepicker date selector, disabling two date selectors (start and end dates)
The JS macro of WPS implements the separation method of picture text in the same paragraph
The applet reads more than 20 data, and the cloud function reads more than 100 restrictions
WPS的JS宏实现图片正文在同一段落的分离方法
transformers PreTrainedTokenizer类
Teach you how to use the reflect package to parse the structure of go - step 1: parameter type check
etcd备份恢复原理详解及踩坑实录
More appropriate development mode under epidemic situation
js滚动div滚动条到底部
[introduction to point cloud dataset]
Getting started with crawler to giving up 06: crawler play Fund (with code)
C language_ Love and hate between string and pointer
Longhorn installation and use
Industrial computer anti cracking
12--合并两个有序链表
OpenCV get(propId) 常用的值