当前位置:网站首页>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 ')
边栏推荐
- App Startup
- 自动化测试的未来趋势
- Swift extension chainlayout (UI chain layout) (source code)
- Online education fades
- transformers PreTrainedTokenizer类
- etcd备份恢复原理详解及踩坑实录
- 2022 mobile crane driver special operation certificate examination question bank and online simulation examination
- Interview tutorial - multi thread knowledge sorting
- 普通token
- 将mysql的数据库导出xxx.sql,将xxx.sql文件导入到服务器的mysql中。项目部署。
猜你喜欢
随机推荐
新技术实战,一步步用Activity Results API封装权限申请库
Robot acceleration level task priority inverse kinematics
Opencv实现图像的基本变换
dhcp、tftp基础
Tool functions – get all files in the project folder
FPGA的虚拟时钟如何使用?
13 -- remove invalid parentheses
Saccadenet: use corner features to fine tune the two stage prediction frame | CVPR 2020
2021-03-09 COMP9021第七节课笔记
For a detailed explanation of flex:1, flex:1
(PKCS1) RSA 公私钥 pem 文件解析
Blue Bridge Cup_ Queen n problem
MySQL source and target table row count check
MAYA重新拓布
2021-03-04 COMP9021第六节课笔记
QOpenGL显示点云文件
The applet reads more than 20 data, and the cloud function reads more than 100 restrictions
Getting started with crawler to giving up 06: crawler play Fund (with code)
App Startup
Solve the problem of notebook keyboard disabling failure









