当前位置:网站首页>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 ')
边栏推荐
- Pagoda panel installation php7.2 installation phalcon3.3.2
- Introduction to RCNN, fast RCNN and fast RCNN
- 常用日期格式符与Qt获取当前时间的办法
- Small sample fault diagnosis - attention mechanism code - Implementation of bigru code parsing
- Synthesize video through ffmpeg according to m3u8 file of video on the network
- Solve the problem of notebook keyboard disabling failure
- Paper notes: multi label learning dm2l
- Scénarios d'utilisation de la promesse
- Swift 基础 闭包/Block的使用(源码)
- Use of swift basic closure /block (source code)
猜你喜欢

Introduction to software engineering - Chapter 2 - feasibility study

List of Li Bai's 20 most classic poems

io模型初探

2021-03-11 comp9021 class 8 notes

直播回顾 | 云原生混部系统 Koordinator 架构详解(附完整PPT)

12-- merge two ordered linked lists

2021-03-16 COMP9021第九节课笔记

jwt(json web token)

2021-03-04 comp9021 class 6 notes

Longhorn installation and use
随机推荐
SQL intra statement operation
【点云数据集介绍】
Fund raising, trading and registration
The JS macro of WPS implements the separation method of picture text in the same paragraph
"Adobe international certification" about Adobe Photoshop, creating and modifying brush tutorials?
ZUCC_编译语言原理与编译_实验08 语法分析 LR 分析
List of Li Bai's 20 most classic poems
pyQt 中 QMenu 响应
LINQ query (2)
Utilisation de la fermeture / bloc de base SWIFT (source)
05-ubuntu安装mysql8
Saccadenet: use corner features to fine tune the two stage prediction frame | CVPR 2020
About the iframe anchor, the anchor is offset up and down, and the anchor has page display problems Srcdoc problem of iframe
jwt(json web token)
独立站运营中如何提升客户留存率?客户细分很重要!
2021-03-09 COMP9021第七节课笔记
工控机防破解
根据网络上的视频的m3u8文件通过ffmpeg进行合成视频
Easyplayerpro win configuration full screen mode can not be full screen why
51 single chip microcomputer_ External interrupt and timer / Counter interrupt