Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I assign an TextInput to an int, in qml?

How do I assign an TextInput to an int, in qml?

int new_span_seconds

TextInput {
        id: editor
        width: 80
        height: 17
        color: "white"
        font.bold: true; font.pixelSize: 14
        text: "21"
        horizontalAlignment: TextInput.AlignHCenter

    }

    Keys.forwardTo: [ (returnKey), (editor)]

    Item {
        id: returnKey
        Keys.onReturnPressed: new_span_seconds = editor. <<< ?  >>>
        Keys.onEnterPressed:  new_span_seconds = editor. <<< ?  >>>
    }
like image 473
user825174 Avatar asked Jul 01 '11 16:07

user825174


1 Answers

It's just a piece of Javascript

Keys.onReturnPressed: new_span_seconds = parseInt(editor.text)
like image 173
blakharaz Avatar answered Oct 24 '22 08:10

blakharaz