当前位置:网站首页>Qtoolbutton available signal
Qtoolbutton available signal
2022-07-03 22:41:00 【。 Seventy two.】
1、 Except those inherited from the parent class , And its own independent signals .
Rewrote triggered() Method , There are also differences in call parameters ; When you click on a action This signal will be triggered , And will acion Objects are passed .
Act on your own signals and tb Like signals sent from the outside ( Type of parameter sent QAciton).
2、 You can bind some data to a given behavior :setData(), Different behaviors bind different data , Access method usage action.data() Method . Than calling directly clicked.connect() Simple method .
import sys
from PyQt5.Qt import *
# Make it into an activity module , Easy to modify
# 1、 Create application , You can pass parameters to app, Enter parameters from the command line
app = QApplication(sys.argv)
window = QWidget()
window.setWindowTitle("QToolButton Use ")
window.resize(500, 500)
tb = QToolButton(window)
tb.setText(" Button ")
tb.setArrowType(Qt.LeftArrow)
tb.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
tb.setAutoRaise(True)
menu = QMenu(tb)
menu.setTitle(" menu ")
# Put submenus and actions in the menu
sub_menu = QMenu(menu)
sub_menu.setTitle(" Sub menu ")
# Put in meun In parent object
action = QAction(" Behavior ", menu)
action.setData([1,2,3])
# monitor action Signal in
#action.triggered.connect(lambda : print(" Clicked behavior "))
menu.addMenu(sub_menu)
menu.addSeparator()
menu.addAction(action)
tb.clicked.connect(lambda: print(" The tool button is clicked "))
tb.setMenu(menu)
# Relevant action object
def do_action(action):
print(" Clicked behavior 2", action.data())
tb.triggered.connect(do_action)
# Modify the popup method of the menu
tb.setPopupMode(QToolButton.InstantPopup)
window.show()
sys.exit(app.exec_())
边栏推荐
- The reason why the computer runs slowly and how to solve it
- [template summary] - binary search tree BST - Basics
- Format cluster and start cluster
- User login function: simple but difficult
- Hcip day 16 notes
- Cesium terrain clipping draw polygon clipping
- Learning notes of raspberry pie 4B - IO communication (SPI)
- Yyds dry goods inventory Prometheus alarm Art
- Pan Yueming helps Germany's Rochester Zodiac custom wristwatch
- [automation operation and maintenance novice village] flask-2 certification
猜你喜欢
Learning notes of raspberry pie 4B - IO communication (SPI)
Go Technology Daily (2022-02-13) - Summary of experience in database storage selection
Team collaborative combat penetration tool CS artifact cobalt strike
The overseas listing of Shangmei group received feedback, and brands such as Han Shu and Yiye have been notified for many times and received attention
Code in keil5 -- use the code formatting tool astyle (plug-in)
[flax high frequency question] leetcode 426 Convert binary search tree to sorted double linked list
Niuke winter vacation training camp 4 g (enumeration optimization, Euler power reduction)
In 2022, 6G development has indeed warmed up
Blue Bridge Cup Guoxin Changtian single chip microcomputer -- led lamp module (V)
Bluebridge cup Guoxin Changtian single chip microcomputer -- hardware environment (I)
随机推荐
In VS_ In 2019, scanf and other functions are used to prompt the error of unsafe functions
WFC900M-Network_ Card/Qualcomm-Atheros-AR9582-2T-2R-MIMO-802.11-N-900M-high-power-Mini-PCIe-Wi-Fi-Mod
Hcip 13th day notes
2022 G3 boiler water treatment registration examination and G3 boiler water treatment examination papers
STM32 multi serial port implementation of printf -- Based on cubemx
Niuke winter vacation training camp 4 g (enumeration optimization, Euler power reduction)
3 environment construction -standalone
Simple solution of m3u8 file format
The 2022 global software R & D technology conference was released, and world-class masters such as Turing prize winners attended
IO flow review
Druids connect to mysql8.0.11
Awk getting started to proficient series - awk quick start
Blue Bridge Cup Guoxin Changtian single chip microcomputer -- software environment (II)
Why should enterprises do more application activities?
LeetCode 1647. Minimum deletion times of unique character frequency
Kali2021.4a build PWN environment
Exclusive download! Alibaba cloud native brings 10 + technical experts to bring "new possibilities of cloud native and cloud future"
Opengauss database log management guide
Quick one click batch adding video text watermark and modifying video size simple tutorial
Pan Yueming helps Germany's Rochester Zodiac custom wristwatch