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. keypressed
Qt 6.11 is out! See what's new in the release blog

keypressed

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 360 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.
  • G Offline
    G Offline
    genli
    wrote on last edited by
    #1

    I would like when I press the A key, the T key will be pressed how I can do please

    void fet::keyPressEvent(QKeyEvent*keyevent)
    {
    switch(keyevent->key())
    {
    case Qt:: Key_A:
    {
    //code
    }
    }

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Do you mean you want to simulate a T KeyPressEvent when A is pressed ?

      How out curiosity, why do you need to do that ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Do you mean you want to simulate a T KeyPressEvent when A is pressed ?

        How out curiosity, why do you need to do that ?

        G Offline
        G Offline
        genli
        wrote on last edited by
        #3

        @SGaist yes that's it

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then create a new QKeyPressEvent and send it.

          But still, you should explain your use case. As a user, pressing one key and having a different one handled is going to feel very awkward.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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