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. Focus problems making a custom spinner
Forum Updated to NodeBB v4.3 + New Features

Focus problems making a custom spinner

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 482 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.
  • U Offline
    U Offline
    uroller
    wrote on last edited by
    #1

    I'm sorry if my terminology is wrong or I'm way off, I'm quite new to QML.

    I'm looking to make a little GUI with QML to change some database entries. One type of value needs a simple spinner that increments the value with the arrow keys.

    The menu is passed a label and an item to get the value from the database:

    @
    import QtQuick 1.0

    Rectangle
    {
    property alias label: label.text;
    property Item value;

    height: 50;
    width: parent.width;
    
    Text {
        id: label;
        // ... other properties
    }
    
    Text {
        id: value_text;
        text: value.get_value();
        // ... other properties
    }
    
    Keys.onPressed:
    {
        if (event.key == Qt.Key_Enter) {
            event.accepted = true;
            value.focus=true;
        }
    }
    

    }
    @

    Getting the value works fine, but I can't figure out how to give the value Item focus. I figured setting value.focus = true would be enough but I never get into the onPressed() handler of my item:

    @
    import QtQuick 1.0

    Item
    {
    property string property_name;

    function get_value() ...
    
    Keys.onPressed:
    {
        if (event.key == Qt.Key_Right) { // decrement value }
    
        if (event.key == Qt.Key_Left) { // increment value }
    }
    

    }
    @

    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