当前位置:网站首页>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_())
边栏推荐
- What are the common computer problems and solutions
- How does sentinel, a traffic management artifact, make it easy for business parties to access?
- Text replacement demo
- Mongoose the table associated with the primary key, and automatically bring out the data of another table
- Pooling idea: string constant pool, thread pool, database connection pool
- On my first day at work, this API timeout optimization put me down!
- ThreadLocal function, scene and principle
- Oil monkey plug-in
- How to solve the problem of requiring a password when accessing your network neighborhood on your computer
- [sg function] 2021 Niuke winter vacation training camp 6 h. winter messenger 2
猜你喜欢

Data consistency between redis and database

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

The 2022 global software R & D technology conference was released, and world-class masters such as Turing prize winners attended

Pooling idea: string constant pool, thread pool, database connection pool

The latest analysis of crane driver (limited to bridge crane) in 2022 and the test questions and analysis of crane driver (limited to bridge crane)

Go Technology Daily (2022-02-13) - Summary of experience in database storage selection
![[Android reverse] use DB browser to view and modify SQLite database (download DB browser installation package | install DB browser tool)](/img/1d/044e81258db86cf34eddd3b8f5cf90.jpg)
[Android reverse] use DB browser to view and modify SQLite database (download DB browser installation package | install DB browser tool)

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

How can enterprises and developers take advantage of the explosion of cloud native landing?

Take you to master the formatter of visual studio code
随机推荐
Redis single thread and multi thread
[template summary] - binary search tree BST - Basics
Leetcode week 4: maximum sum of arrays (shape pressing DP bit operation)
[dynamic planning] counting garlic customers: the log of garlic King (the longest increasing public subsequence)
Can you draw with turtle?
Electronic tube: Literature Research on basic characteristics of 6j1
Codeforces Round #768 (Div. 1)(A-C)
[Android reverse] use DB browser to view and modify SQLite database (download DB browser installation package | install DB browser tool)
Ansible common usage scenarios
Ten minutes will take you in-depth understanding of multithreading. Multithreading on lock optimization (I)
STM32 multi serial port implementation of printf -- Based on cubemx
QGIS grid processing DEM data reclassification
Preliminary analysis of smart microwave radar module
How to solve win10 black screen with only mouse arrow
Kali2021.4a build PWN environment
Exclusive download! Alibaba cloud native brings 10 + technical experts to bring "new possibilities of cloud native and cloud future"
[sg function]split game (2020 Jiangxi university student programming competition)
[flax high frequency question] leetcode 426 Convert binary search tree to sorted double linked list
Morning flowers and evening flowers
Blue Bridge Cup Guoxin Changtian MCU -- program download (III)