当前位置:网站首页>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_())
边栏推荐
- [automation operation and maintenance novice village] flask-2 certification
- The reason why the computer runs slowly and how to solve it
- 540. Single element in ordered array
- Pooling idea: string constant pool, thread pool, database connection pool
- SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]
- Sow of PMP
- Some 5000+ likes, the development notes of a director of cosmic factory, leaked
- How to switch between dual graphics cards of notebook computer
- DR882-Qualcomm-Atheros-QCA9882-2T2R-MIMO-802.11ac-Mini-PCIe-Wi-Fi-Module-5G-high-power
- Morning flowers and evening flowers
猜你喜欢

In 2022, 6G development has indeed warmed up
![[dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)](/img/6c/2d48d441fee1981a271319fd9f6c23.jpg)
[dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)
![[SRS] build a specified version of SRS](/img/01/0d2d762e01b304220b8924d20277e3.jpg)
[SRS] build a specified version of SRS

Blue Bridge Cup Guoxin Changtian single chip microcomputer -- software environment (II)

Hcip day 14 notes

Programming language (1)
![[automation operation and maintenance novice village] flask-2 certification](/img/9a/a9b45e1f41b9b75695dcb06c212a69.jpg)
[automation operation and maintenance novice village] flask-2 certification

Summary of fluent systemchrome

What are the common computer problems and solutions

IO flow review
随机推荐
Blue Bridge Cup Guoxin Changtian single chip microcomputer -- led lamp module (V)
Blue Bridge Cup -- Mason prime
Errors taken 1 Position1 argument but 2 were given in Mockingbird
Leetcode week 4: maximum sum of arrays (shape pressing DP bit operation)
Subset enumeration method
Opengauss database log management guide
Yyds dry goods inventory hands-on teach you to create a jigsaw puzzle using the canvasapi
How to solve the problem of computer networking but showing no Internet connection
pivot ROP Emporium
Es6~es12 knowledge sorting and summary
Programming language (2)
Hcip day 12 notes
LeetCode 1646. Get the maximum value in the generated array
In VS_ In 2019, scanf and other functions are used to prompt the error of unsafe functions
Uboot migration
Classification and extension of OC
C deep anatomy - the concept of keywords and variables # dry inventory #
Esp-idf turns off serial port log output.
2 spark environment setup local
On my first day at work, this API timeout optimization put me down!