Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Qt] QWidget shortcuts are Not Working when i tried to overwrite it
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 663 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mishra.rakesh510ra
    wrote on last edited by
    #1

    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_())
    

    @

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved