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. Receive key strokes inside QtQuick.Dialogs 1.2? (How to deal with the focus)
Forum Updated to NodeBB v4.3 + New Features

Receive key strokes inside QtQuick.Dialogs 1.2? (How to deal with the focus)

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
focus issuefocusscopedialog
1 Posts 1 Posters 629 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.
  • C Offline
    C Offline
    c64zottel
    wrote on last edited by
    #1
    Button {
           onPressed: {
               dialog.open()
               f.focus = true
           }
    
           text: "Record key"
       }
    
    Dialog {
           id: dialog
    
           contentItem: Rectangle {
               color: f.activeFocus ? "red" : "yellow"
               focus: true
               implicitHeight:  200
               implicitWidth:   300
                   Text {
                       id: f
                       anchors.fill: parent
                       focus: true
                       anchors.centerIn: parent
                       text: "Press key"
    
                       Keys.onPressed: {
                           focus: true
                           console.log( "Key: " + event.key )
                      }
                }
           }
    }
    

    Is there a better way to make a Dialog listening to a single key stroke? I fiddled around with FocusScope but I could not get anything working, except the version where the focus is set manually outside the dialog.

    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