user6285273
user6285273

Reputation:

Move popup when device's (android) keyboard is active

I would like to move the popup, when keyboard is active, because right now keyboard covers the popup. How can I know sizes of keyboard to properly move popup?

Popup {
    id: popupName
    contentWidth: parent.width/2
    contentHeight: parent.height/2

    x: parent.width/2 - popupName.width/2
    y: parent.height/2 - popupName.height/2

    background: Rectangle {
        color: "#424242"
    }

enter image description here

Upvotes: 1

Views: 521

Answers (1)

Mitch
Mitch

Reputation: 24416

You might be able to use Qt.inputMethod.keyboardRectangle:

The inputMethod object allows access to application's QInputMethod object and all its properties and slots. See the QInputMethod documentation for further details.

The docs for QInputMethod say:

This property holds virtual keyboard's geometry in window coordinates.

This might be an empty rectangle if it is not possible to know the geometry of the keyboard. This is the case for a floating keyboard on android.

I'm not sure if the keyboard in your screenshot is considered a "floating keyboard" or not.

Upvotes: 2

Related Questions