如何重载PyQt中的任何方法
class Main_Window( QMainWindow):
def __init__(self, parent = None):
super(Main_Window,self).__init__(parent)
self.initUI()
def initUI(self):
dialog_window = QAction( '&Create Plugin', self
dialog_window.triggered.connect(self.showdialog)
toolbar = self.addToolBar('Exit')
# toolbar.addAction(QIcon("plugin0.png"),'',self.showdialog)
我想重载QToolBar.addAction(self,QIcon图标,可调用接收器)
.........
toolbar.addAction(QIcon("plugin0.png"),self.showdialog)
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('Menubar')
self.show()
def showdialog(self):
d = Dialog_window()
d.exec_()
def main():
app = QApplication(sys.argv)
ex = Main_Window()
sys.exit(app.exec_())
答案 0 :(得分:0)
一个小小的例子......
class MyToolBar( QToolBar ) :
"""Class doc
"""
def __init__( self, parent ) :
"""Class initialiser
"""
QToolBar.__init__( self, parent )
def addAction( self, icn, func ) :
act = QAction( icon, QString(), self )
self.addAction( act )