3
votes

I have qml button file that I want to be visible above the keyboard when the keyboard is visible.

I just want to know what I should do with my QmlApplicationViewer so that my small qml block is always visible on top of all other applications but you should still have access to the application below.

I have already implemented a way for the file to become visible when the keyboard is visible and I can easily get it right above the keyboard later but now I am struggling to prevent it from stealing focus and closing the keyboard, because the moment a keyboard is opened my button appears and the keyboard closes. The moment I close my app the button disappears and the keyboard reopens in the app where I originally opened it. I want this to be a background task which supplements the keyboard functionality, the button will allow for speech input.

main.qml:

import QtQuick 1.1
import com.nokia.symbian 1.1

Button{
    signal keyActive()

    x: 0
    y: 0
    text: "Voice"
    property bool bob: inputContext.visible
    onBobChanged: console.log("keyboard" + bob), bob ? keyActive() : null
}

main.cpp:

#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"
#include <QObject>
#include <QGraphicsObject>

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QmlApplicationViewer viewer;
    viewer.setMainQmlFile(QLatin1String("qml/topwidget/main.qml"));

    viewer.setWindowFlags(Qt::WindowStaysOnTopHint);
    viewer.setAttribute(Qt::WA_ShowWithoutActivating);
    viewer.move(10, 20);
    viewer.releaseKeyboard();
    viewer.show();

    QObject *rootObject = viewer.rootObject();
    QObject::connect(rootObject, SIGNAL(keyActive()), &viewer, SLOT(raise()));

    return app.exec();
}

PS. I do know when the keyboard opens and closes, all I want to know is how to display my button without the keyboard automatically closing?

1
Can't you install an event filter, or subscribe to the keyboard event in some way. Then once you get intrrupted by state changes in the keybaord - you can deal with it accordingly: developer.nokia.com/Community/Discussion/… - ddoor
Yes but what I'm asking is how to deal with it? - Gerharddc
Do you have any idea how I can deal with it once I know that the keyboard is active? - Gerharddc

1 Answers

0
votes

You are manipulating x and y but what you want is to control overlap, which is z. So you can affect what is always on top by giving it a special z value. See here:

http://qt-project.org/doc/qt-4.8/qml-item.html#z-prop