在PyQt5工具栏添加图标并绑定点击事件,点击后显示长尾词如何快速查询?
- 内容介绍
- 文章标签
- 相关推荐
本文共计286个文字,预计阅读时间需要2分钟。
自己最近做的软件需要一个工具栏,点击工具栏的图标需要进行一定的操作。创建工具栏主窗口口,添加工具栏addToolBar。创建工具栏按钮refresf_button,添加图标+,点击按钮进行操作。
自己最近做的软件需要一个工具栏,然后点击工具栏的图标需要进行一定的操作创建工具栏toolBar主窗口添加工具栏addToolBar创建工具按钮refresf_button按钮添加图自己最近做的软件需要一个工具栏,然后点击工具栏的图标需要进行一定的操作
- 创建工具栏 toolBar
- 主窗口添加工具栏 addToolBar
- 创建工具按钮 refresf_button
- 按钮添加图标与文字
- 连接按钮点击事件
- 工具栏添加按钮 toolBar.addWidget(refrefh_botton)
self.toolBar = QToolBar(MainWindow)self.toolBar.setObjectName("toolBar")self.toolBar.setContentsMargins(QMargins(20, 0, 20, 0))MainWindow.addToolBar(Qt.TopToolBarArea, self.toolBar)self.refresh_button = QPushButton()self.refresh_button.setText('刷新')refresh_icon = QIcon()refresh_icon.addPixmap(QPixmap('../images/refresh.png'), QIcon.Normal, QIcon.Off)self.refresh_button.setIcon(refresh_icon)self.refresh_button.setIconSize(QSize(25, 25))self.refresh_button.setStyleSheet(QSS.ButtonStyle)self.refresh_button.clicked.connect(self.refresh_treewidget)self.toolBar.addWidget(self.refresh_button)
本文共计286个文字,预计阅读时间需要2分钟。
自己最近做的软件需要一个工具栏,点击工具栏的图标需要进行一定的操作。创建工具栏主窗口口,添加工具栏addToolBar。创建工具栏按钮refresf_button,添加图标+,点击按钮进行操作。
自己最近做的软件需要一个工具栏,然后点击工具栏的图标需要进行一定的操作创建工具栏toolBar主窗口添加工具栏addToolBar创建工具按钮refresf_button按钮添加图自己最近做的软件需要一个工具栏,然后点击工具栏的图标需要进行一定的操作
- 创建工具栏 toolBar
- 主窗口添加工具栏 addToolBar
- 创建工具按钮 refresf_button
- 按钮添加图标与文字
- 连接按钮点击事件
- 工具栏添加按钮 toolBar.addWidget(refrefh_botton)
self.toolBar = QToolBar(MainWindow)self.toolBar.setObjectName("toolBar")self.toolBar.setContentsMargins(QMargins(20, 0, 20, 0))MainWindow.addToolBar(Qt.TopToolBarArea, self.toolBar)self.refresh_button = QPushButton()self.refresh_button.setText('刷新')refresh_icon = QIcon()refresh_icon.addPixmap(QPixmap('../images/refresh.png'), QIcon.Normal, QIcon.Off)self.refresh_button.setIcon(refresh_icon)self.refresh_button.setIconSize(QSize(25, 25))self.refresh_button.setStyleSheet(QSS.ButtonStyle)self.refresh_button.clicked.connect(self.refresh_treewidget)self.toolBar.addWidget(self.refresh_button)

