当前位置:网站首页>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_())
边栏推荐
- 2022 G3 boiler water treatment registration examination and G3 boiler water treatment examination papers
- SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]
- Yyds dry goods inventory Prometheus alarm Art
- Blue Bridge Cup Guoxin Changtian single chip microcomputer -- software environment (II)
- (POJ - 2912) rochambau (weighted concurrent search + enumeration)
- string
- Niuke winter vacation training camp 4 g (enumeration optimization, Euler power reduction)
- Sort merge sort
- BUUCTF,Misc:LSB
- Get current JVM data
猜你喜欢

SDMU OJ#P19. Stock trading

Ppt image processing

Exclusive download! Alibaba cloud native brings 10 + technical experts to bring "new possibilities of cloud native and cloud future"

2022 safety officer-b certificate examination summary and safety officer-b certificate simulation test questions

The latest analysis of R1 quick opening pressure vessel operation in 2022 and the examination question bank of R1 quick opening pressure vessel operation

Wisdom tooth technology announced that it had completed the round D financing of US $100million and had not obtained a valid patent yet
![[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)

MLX90614 driver, function introduction and PEC verification

On my first day at work, this API timeout optimization put me down!

Data consistency between redis and database
随机推荐
Wisdom tooth technology announced that it had completed the round D financing of US $100million and had not obtained a valid patent yet
Niuke winter vacation training camp 4 g (enumeration optimization, Euler power reduction)
33 restrict the input of qlineedit control (verifier)
Bluebridge cup Guoxin Changtian single chip microcomputer -- hardware environment (I)
SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]
Ten minutes will take you in-depth understanding of multithreading. Multithreading on lock optimization (I)
DR882-Qualcomm-Atheros-QCA9882-2T2R-MIMO-802.11ac-Mini-PCIe-Wi-Fi-Module-5G-high-power
pycuda._ driver. LogicError: explicit_ context_ dependent failed: invalid device context - no currently
[golang] leetcode intermediate - alphabetic combination of island number and phone number
JS closure knowledge points essence
Take you to master the formatter of visual studio code
How to obtain opensea data through opensea JS
LeetCode 1646. Get the maximum value in the generated array
Summary of fluent systemchrome
[Android reverse] use the DB browser to view and modify the SQLite database (copy the database file from the Android application data directory | use the DB browser tool to view the data block file)
Weekly leetcode - nc9/nc56/nc89/nc126/nc69/nc120
Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
Format cluster and start cluster
Overview of Yunxi database executor
Go Technology Daily (2022-02-13) - Summary of experience in database storage selection