当前位置:网站首页>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 ')
边栏推荐
- JS scroll div scroll bar to bottom
- How to design a highly available and extended image storage function
- dhcp、tftp基础
- 2021-03-04 COMP9021第六节课笔记
- (PKCS1) RSA 公私钥 pem 文件解析
- etcd备份恢复原理详解及踩坑实录
- 51 single chip microcomputer_ External interrupt and timer / Counter interrupt
- 2021-03-09 comp9021 class 7 Notes
- longhorn安装与使用
- App Startup
猜你喜欢

longhorn安装与使用

Opencv实现图像的基本变换

Swift 基础 Swift才有的特性

2021-03-11 COMP9021第八节课笔记

【微服务~Nacos】Nacos服务提供者和服务消费者

Blue Bridge Cup_ Queen n problem

Small sample fault diagnosis - attention mechanism code - Implementation of bigru code parsing

ZUCC_编译语言原理与编译_实验08 语法分析 LR 分析

About the iframe anchor, the anchor is offset up and down, and the anchor has page display problems Srcdoc problem of iframe

LabVIEW查找n个元素数组中的质数
随机推荐
Installation and use of selenium IDE
[graduation season] Hello stranger, this is a pink letter
[acnoi2022] I have done it, but I can't
11--无重复字符的最长子串
About the iframe anchor, the anchor is offset up and down, and the anchor has page display problems Srcdoc problem of iframe
Review SGI STL secondary space configurator (internal storage pool) | notes for personal use
Opening chapter of online document technology - rich text editor
WCF TCP protocol transmission
新准则金融资产三分类:AMC、FVOCI和FVTPL
Nodejs redlock notes
Solve the problem of notebook keyboard disabling failure
JVM underlying principle analysis
2021-03-09 comp9021 class 7 Notes
List of Li Bai's 20 most classic poems
PAT 1157:校庆
Getting started with ffmpeg
Promise的使用場景
Qt导出PDF文件的两种方法
js滚动div滚动条到底部
2021-03-11 COMP9021第八节课笔记