[Qt] QWidget shortcuts are Not Working when i tried to overwrite it



  • Hi All,
    whenever i tried to over write QWidget actions with shortcuts, then i am finding that shortcut is not working,
    can any one help me to find out the reason.

    please find the example code from below.
    Thanks
    Rakesh

    @from PySide import QtCore, QtGui

    class TextBrowser(QtGui.QTextEdit):
    def init(self,parent=None):
    QtGui.QTextEdit.init(self,parent)
    self.copyAction = QtGui.QAction("COPY ", self)
    self.copyAction.setShortcut('Ctrl+C')
    QtCore.QObject.connect(self.copyAction, QtCore.SIGNAL('triggered()'), self.fun)
    self.addAction(self.copyAction)
    def mousePressEvent(self, *args, **kwargs):
    print "mouse click event",self.actions()

        return QtGui.QTextEdit.mousePressEvent(self, *args, **kwargs)
        self.copyAction.setShortcut('Ctrl+C')
    def focusInEvent(self, *args, **kwargs):
        print "focus in evemt"
        return QtGui.QTextEdit.focusInEvent(self, *args, **kwargs)
    def focusOutEvent(self, *args, **kwargs):
        print "focus out event"
        return QtGui.QTextEdit.focusOutEvent(self, *args, **kwargs)
    def fun(self):
        print "funciton"
    

    class Window(QtGui.QWidget):
    def init(self):
    QtGui.QWidget.init(self)
    self.setWindowTitle('Dock Widgets')
    self.button = QtGui.QPushButton('click')

        dock = QtGui.QDockWidget("log1")
        self.logWidget=TextBrowser(dock)
        
        dock2 = QtGui.QDockWidget("log2")
        self.logWidget2=QtGui.QTextBrowser(dock2)
        self.logWidget2.setOpenLinks(False)
        #self.logWidget2.setReadOnly(True)
        layout=QtGui.QHBoxLayout()
        layout.addWidget(dock)
        layout.addWidget(self.button)
        layout.addWidget(dock2)
        self.setLayout(layout)
        self.button.clicked.connect(self.fun)
        
        
    def fun(self):
        self.logWidget.append("test")
        self.logWidget2.append("test")
    

    if name == 'main':

    import sys
    app = QtGui.QApplication(sys.argv)
    window = Window()
    window.show()
    sys.exit(app.exec_())
    

    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.