Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

If you're building a QtQuick 2.0 app, what is the procedure for specifying that the soft-keyboard should be selectable/expandable at the bottom of the screen?

share|improve this question
    
Still need to test it, but it looks like as of Qt 5 you can just "Qt.inputMethod.show()" qt-project.org/doc/qt-5.0/qtquick/qtquick-porting-qt5.html –  hbdgaf Apr 20 '13 at 12:39

1 Answer 1

up vote 0 down vote accepted

Here is some un-styled sample code that just gets the keyboard on-screen. The docs indicate that you need to have a text-entry selected for this to work, so if you have a custom widget, you may have to sub-class text-entry or set up a particular slot/signal.

import QtQuick 2.0
import Ubuntu.Components 0.1

MainView {
    // objectName for functional testing purposes (autopilot-qt5)
    objectName: "mainView"
    id: "mainview"
    applicationName: "QMLTerminal"

    width: units.gu(100)
    height: units.gu(75)
    property bool keyShowing: false
    TextEdit {
        id: textConsumer
        visible: false
        anchors.top: parent.top
        width: parent.width
        height: parent.height * .10
    }

    MouseArea {
        anchors.fill: parent
        onClicked: if (mainview.keyShowing){
                       Qt.inputMethod.hide()
                       mainview.keyShowing = false
                       textConsumer.visible = false
                       console.log("Tried to hide")
                   } else {
                       textConsumer.visible = true
                       textConsumer.focus = true
                       Qt.inputMethod.show()
                       mainview.keyShowing = true
                       console.log("Tried to show")
                   }
    }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.