Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qml TextEdit Custom key event not processed properly
Forum Updated to NodeBB v4.3 + New Features

Qml TextEdit Custom key event not processed properly

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 241 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.
  • C Offline
    C Offline
    chilarai
    wrote on last edited by
    #1

    I wanted to add custom key events to a TextEdit. But, it seems key events are not properly processed inside TextEdit.

    For example, in the code below, I am trying to handle Space key events. Although the Space keypress is recognized by the signal handler function, the output text does not contain a space. It is the same for all other key events. How do I overcome this?

    import QtQuick 2.15
    import QtQuick.Controls 2.15
    
    Item{
    
        function processSpace(event){
            event.accepted = true
            console.log(xTextEdit.text)
        }
    
        TextEdit{
            id: xTextEdit
            height: parent.height
            width: parent.width
            Keys.onSpacePressed: processSpace(event)
        }
    }
    
    1 Reply Last reply
    0
    • C Offline
      C Offline
      chilarai
      wrote on last edited by
      #2

      Seems like I have to write event.accepted = false and then it works

      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