当前位置:网站首页>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 ')
边栏推荐
- 貸款五級分類
- os. path. Pits encountered during the use of join()
- 小样本故障诊断 - 注意力机制代码 - BiGRU代码解析实现
- June 27, 2021: given a positive array arr, it represents the weight of several people
- All you know is the test pyramid?
- For a detailed explanation of flex:1, flex:1
- Dart development server, do I have a fever?
- Getting started with crawler to giving up 06: crawler play Fund (with code)
- etcd备份恢复原理详解及踩坑实录
- Question 3 - MessageBox pop-up box, modify the default background color
猜你喜欢

MAYA重新拓布

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

longhorn安装与使用

ZUCC_编译语言原理与编译_实验02 FSharp OCaml语言

Swift 基础 闭包/Block的使用(源码)

Pat 1157: school anniversary

Model effect optimization, try a variety of cross validation methods (system operation)

ZUCC_编译语言原理与编译_实验04 语言与文法

12-- merge two ordered linked lists

How to use the virtual clock of FPGA?
随机推荐
JVM underlying principle analysis
Review SGI STL secondary space configurator (internal storage pool) | notes for personal use
PAT 1157:校庆
transformers PreTrainedTokenizer类
JS scroll div scroll bar to bottom
貸款五級分類
Fund raising, trading and registration
pyQt 常用系统的事件
Blue Bridge Cup_ Queen n problem
Five level classification of loans
VsCode主题推荐
Industrial computer anti cracking
Introduction to RCNN, fast RCNN and fast RCNN
Four models of iPhone 13 series have been exposed, and indeed, they are 13 fragrant!
【点云数据集介绍】
工控机防破解
新技术实战,一步步用Activity Results API封装权限申请库
os.path.join()使用过程中遇到的坑
蓝桥杯_N 皇后问题
2021-03-09 comp9021 class 7 Notes