Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Confused about keypress event
Qt 6.12 LTS is out! See what's new in the release blog

Confused about keypress event

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 2.0k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi,
    Im using pyside, and I am loading a ui file from designer with QUiLoader.

    @class MyWidget(QtGui.QMainWindow):
    def init(self, *args):
    apply(QtGui.QMainWindow.init, (self,) + args)

    loader = QtUiTools.QUiLoader()
    file = QtCore.QFile("pyside_demo.ui")
    file.open(QtCore.QFile.ReadOnly)
    self.ui = loader.load(file, self)
    file.close()

    def keyPressEvent(self, e):
    print "a key was pressed"
    if e.key() == QtCore.Qt.Key_Escape:
    print "escape was pressed"

    def show(self):
    self.ui.show()@

    I dont really know how to get the keypress event to work - at the moment it does not - any clues?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lndn
      wrote on last edited by
      #2

      Perhaps you can upload your files somewhere so other people can try it on their local machine.

      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
      • Unsolved