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. QGraphicsScene does not receive keyPressEvent
Forum Updated to NodeBB v4.3 + New Features

QGraphicsScene does not receive keyPressEvent

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.1k Views
  • 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.
  • clostridium_difficileC Offline
    clostridium_difficileC Offline
    clostridium_difficile
    wrote on last edited by
    #1

    QGraphicsScene does not receive keyPressEvent. How to fix it?

    JonBJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Can you please be a little bit more precise on your problem and what you are trying to do? A scene is no widget nor does display anything so how should it receive a key event?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • clostridium_difficileC clostridium_difficile

        QGraphicsScene does not receive keyPressEvent. How to fix it?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @clostridium_difficile
        Google for: QGraphicsScene does not receive keyPressEvent

        Assuming you are meaning a QGraphicsView, there are plenty of examples. Maybe this one in our forum:
        https://forum.qt.io/topic/74169/capturing-key-press-in-qgraphicsview-within-main-function

        1 Reply Last reply
        1
        • clostridium_difficileC Offline
          clostridium_difficileC Offline
          clostridium_difficile
          wrote on last edited by
          #4

          QGraphicsScene receives mouse events, but does not receive key press events? I want rotate some items in scene, once key is pressed.

          JonBJ 1 Reply Last reply
          0
          • clostridium_difficileC clostridium_difficile

            QGraphicsScene receives mouse events, but does not receive key press events? I want rotate some items in scene, once key is pressed.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @clostridium_difficile
            Let's start again. There is https://doc.qt.io/qt-5/qgraphicsscene.html#keyPressEvent

            This event handler, for event keyEvent, can be reimplemented in a subclass to receive keypress events. The default implementation forwards the event to current focus item.

            There is also https://doc.qt.io/qt-5/qgraphicsview.html#keyPressEvent

            Reimplements: QAbstractScrollArea::keyPressEvent(QKeyEvent *e).

            What is not working for you?

            @Christian-Ehrlicher

            A scene is no widget nor does display anything so how should it receive a key event?

            I thought the same as you initially, yet nonetheless there is https://doc.qt.io/qt-5/qgraphicsscene.html#keyPressEvent, and similar for mousey events?

            1 Reply Last reply
            1

            • Login

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