我想在PyQt工具欄中顯示按下(具有藍色背景)的特定按鈕。假設當我打的工具欄按鈕,我想作爲壓PyQt如何使一個工具欄按鈕出現按下
import sys
from PyQt4 import QtGui, QtCore
from PyQt4.QtGui import *
from PyQt4.QtCore import *
class Window(QtGui.QMainWindow):
def __init__(self):
super(Window, self).__init__()
self.setGeometry(50, 50, 700, 700)
self.setWindowTitle('Rich Text Editor')
self.statusBar = QStatusBar()
self.textEdit = QtGui.QTextEdit()
self.setCentralWidget(self.textEdit)
self.setStatusBar(self.statusBar)
self.home()
def home(self):
changeBoldActionTB = \
QtGui.QAction(QtGui.QIcon('bold-text-option.png'),
'Make the text bold', self)
changeBoldActionTB.triggered.connect(self.changeBold)
self.formatbar = QToolBar()
self.addToolBar(Qt.TopToolBarArea, self.formatbar)
self.formatbar.addAction(changeBoldActionTB)
self.show()
def changeBold(self):
pass
#I think this does't matter
def run():
app = QtGui.QApplication(sys.argv)
GUI = Window()
sys.exit(app.exec_())
run()
我有兩個toolbars.I我打算使用cursorPositionChanged要做到這一點,但它仍然將是出現在有一個PyQt的方式來做到這一點
reproduible代碼: https://files.fm/u/h4c2amdx
我想按鈕的背景改爲blue.Its圖像按鈕 –
我想按鈕的背景變成藍色,它是一個圖像按鈕 –
是的,我想這樣做 –