当前位置:网站首页>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_())
边栏推荐
- Blue Bridge Cup Guoxin Changtian single chip microcomputer -- software environment (II)
- ThreadLocal function, scene and principle
- 3 environment construction -standalone
- 540. Single element in ordered array
- Blue Bridge Cup -- Mason prime
- Development mode and Prospect of China's IT training industry strategic planning trend report Ⓣ 2022 ~ 2028
- 2022 electrician (elementary) examination questions and electrician (elementary) registration examination
- Ansible common usage scenarios
- Programming language (1)
- MLX90614 driver, function introduction and PEC verification
猜你喜欢

Preliminary analysis of smart microwave radar module
![[dynamic planning] counting garlic customers: the log of garlic King (the longest increasing public subsequence)](/img/29/543dce2f24130d22c1824385fbfa8f.jpg)
[dynamic planning] counting garlic customers: the log of garlic King (the longest increasing public subsequence)

Kali2021.4a build PWN environment

2022 electrician (elementary) examination questions and electrician (elementary) registration examination

Leetcode week 4: maximum sum of arrays (shape pressing DP bit operation)

User login function: simple but difficult

Programming language (1)

C deep anatomy - the concept of keywords and variables # dry inventory #

Code in keil5 -- use the code formatting tool astyle (plug-in)

Hcip day 12 notes
随机推荐
Sort merge sort
How the computer flushes the local DNS cache
How to solve the problem of requiring a password when accessing your network neighborhood on your computer
WiFi 2.4g/5g/6g channel distribution
Teach you how to run two or more MySQL databases at the same time in one system
Opengauss database log management guide
Morning flowers and evening flowers
Programming language (1)
Preliminary analysis of smart microwave radar module
33 restrict the input of qlineedit control (verifier)
User login function: simple but difficult
320. Energy Necklace (ring, interval DP)
Plug - in Oil Monkey
JS closure knowledge points essence
How to obtain opensea data through opensea JS
IDENTITY
IPhone development swift foundation 08 encryption and security
Common problems in multi-threaded learning (I) ArrayList under high concurrency and weird hasmap under concurrency
Rest reference
WFC900M-Network_ Card/Qualcomm-Atheros-AR9582-2T-2R-MIMO-802.11-N-900M-high-power-Mini-PCIe-Wi-Fi-Mod