Virtual keyboard unfocus possible with Qt ?



  • Hi .

    I try to make a little virtual keyboard in c++ with Qt.

    I maked all code and normally he should works fine . But my currently problem is when I when try to wrote (by exemple) in a notepad.

    My virtual keyboard get the focus when i click on him (with my 2 versions linux and windows) so when I try to get the active windows (it returns me my keyboard ><).

    for my example I put the code of my keyboard for windows :

    this is to define the actual current window :

    @HWND Fore = GetForegroundWindow();
    QWidget *test=QWidget::find((HWND)Fore);

        QMessageBox::information(this,"test",test->windowTitle());@
    

    I inclue <windows.h> for this one but I think (QApplication::activeWindow() work fine too) .

    I tried this for restrict the focus on my keyboard :

    @ this->setWindowFlags(Qt::WindowStaysOnTopHint);
    this->setFocusPolicy(Qt::NoFocus);@

    WindowsStaysOnTopHint it's for block my keyboard to the top of screen .

    setFocusPolicy(Qt::NoFocus) it's for try to denied the focus (didn't work :s) .

    So I write you to find help on my probleme . Does Qt really takes care about focus of OS ? If it's possible how can I reject the focus ?

    PS:sorry for my bad english Q_Q it isn't my native language

    Thanks a lot for your help and see you soon ;) .



  • Nobody have a solution ?

    This probleme must be important I think so :x .


  • Moderators

    Have you tried focusing some other widget that does not need the keyboard? I have not tried doing that, but would expect that to work.



  • [quote author="Tobias Hunger" date="1333043397"]Have you tried focusing some other widget that does not need the keyboard? I have not tried doing that, but would expect that to work.[/quote]

    I think you speak focus the other app .

    And Yes, with all my test I perm check if I click on the notepad write zone (the cursor appear on it). But when I click on a button of my keyboard to wrote a character in notepad (extern app) my keyboard get the focus .

    So when i tried to define who have the focus that return me my keyboard :/ .

    I explain my exemple with a notepad,but that can be a cmd,word doc,etc,etc .., that why I need to determinate the window who have focus .

    I hope to be included with this explanation: x, sorry again for my English medium

    but thanks Tobias to help me ;)


  • Moderators

    No, I was not referring to which application has the focus but which widget in that application has it. If you focus a text edit, then it makes sense for the keyboard to pop up. If you move focus to some button or something that does not allow text input, then I would expect the keyboard to hide again.

    Most likely there are also direct means to control the keyboard (maybe platform specific)... but as I already said, I work on the desktop most of the time and never had to bother much with virtual keyboards there. Sorry.



  • oh Ok .

    I need te explain more of my project :P .

    I actually devellop an application for the agriculture . My program will be installed on a linux OS (debian) , and this pc-board will be mounted on a vehicle resembling a "wheelbarrow" .

    The screen is a touch screen so we need use virtual keyboard for use my app and the OS too.
    By default on this OS GOK permit to get a virtual keyboard ,but it is very ugly and when i call him with my application (QProcess::startDetached("GOK --keyboard") ) it is contain little bug .

    So I decided to make a virtual keyboard .

    First I make the keyboard for QWidget (my app is the parent of it) with help of multi tutorial on web . It works fine, but just for my app :/ .

    So I tried since 2 weeks to make a "general" virtual keyboard (detect automatically the focussed windows).

    That why I cant just restrict the focused window when I use my keyboard, because it must be general and works with all app installed on Debian and with Debian too :x.

    It's for that I post this thread for know if Qt can be stop the focus on app ? Because without this we can't determined the real focused app in background.



  • little bump ;) .

    nobody have other solutions ? :x



  • little bump of last chance ?

    Impossible problem ? :x



  • Hi Bloops,

    Did you solve your problem? Is your code opensource? Can you share the solution?

    Thanks



  • Hi... Please check this link. This might help someone with the same problem.

    "http://qt-project.org/forums/viewthread/47407/#194982":


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.