Results 1 to 12 of 12

Thread: How to hide virtual keyboard in Qt?

  1. #1
    Join Date
    Sep 2016
    Location
    U.K.
    Posts
    16
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default How to hide virtual keyboard in Qt?

    Hi all,

    I have a very simple code to start/show the virtual keyboard which works fine

    Qt Code:
    1. keyboard = new Keyboard(this);
    To copy to clipboard, switch view to plain text mode 

    but I can not hide it dynamically I have tried

    Qt Code:
    1. keyboard->disconnect();
    To copy to clipboard, switch view to plain text mode 
    also this
    Qt Code:
    1. keyboard->deleteLater();
    To copy to clipboard, switch view to plain text mode 

    Has anyone got any suggestions please.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to hide virtual keyboard in Qt?

    How about simply calling hide() or show()?

    disconnect() has nothing to do with visiblility - it simply disconnects any slots the keyboard signals are connected to. Likewise deleteLater() simply tells Qt to delete the keyboard instance the next time through the event loop (which will hide it and destroy the instance).
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Sep 2016
    Location
    U.K.
    Posts
    16
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to hide virtual keyboard in Qt?

    Thanks for your reply, 'keyboard' is a pointer I don't get hide() or show() methods as options, the only relevant methods I get are 'disconnect()' or 'deleteLater()' . I can't be this difficult to hide or disconnect a virtual keyboard can it ?

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to hide virtual keyboard in Qt?

    'keyboard' is a pointer
    A pointer to what? You create it with "new Keyboard()" so somewhere you must have a "keyboard.h" or other header file where the Keyboard class is defined. That will tell you where the Keyboard class sits in the Qt class hierarchy. If it is derived from QWidget somewhere back along the line, then it inherits show() and hide() methods from QWidget.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Sep 2016
    Location
    U.K.
    Posts
    16
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to hide virtual keyboard in Qt?

    Thanks again, you're right it's a pointer to a class the only difference is that it's derived from QObject and not from QWidget, do you think that's the reason I'm not seeing hide() and show() methods ?

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to hide virtual keyboard in Qt?

    do you think that's the reason I'm not seeing hide() and show() methods ?
    Of course. But a QObject has no on-screen visibility, so what you are creating using the Keyboard class cannot be the virtual keyboard you see on the screen. Only things derived from QWidget (or things in the QGraphicsItem hierarchy) can have an on-screen appearance. It sounds to me as though your Keyboard class is just something that is a component of something else that displays a keyboard on screen.

    Maybe you can post a link to whatever it is that you are using so we can better understand it? This seems like it isn't your code and that you got it from somewhere. Where is that?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  7. #7
    Join Date
    Sep 2016
    Location
    U.K.
    Posts
    16
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to hide virtual keyboard in Qt?

    This is the class I'm invoking wherever I need the keyboard, I hope it gives you a little idea where I'm going wrong.

    Qt Code:
    1. #include "keyboard.h"
    2. #include <QProcess>
    3.  
    4. #ifdef WIN32
    5. #include <windows.h>
    6. #include <QString>
    7. #include <QStringList>
    8. #include <QDebug>
    9. #endif
    10.  
    11.  
    12. #include "entrysettings.h"
    13.  
    14. Keyboard::Keyboard(QObject *parent) : QObject(parent), process(0)
    15. {
    16. #ifdef WIN32
    17.  
    18. QString program = "explorer.exe";
    19. QString folder = "C:\\Windows\\System32\\osk.exe";
    20. QString tt = "C:\\Progra~1\\Common~1\\micros~1\\ink\\TabTip.exe";
    21.  
    22. if( EntrySettings::windowsMajorVersion() >= 10 ) {
    23. qDebug() << "Setting Win 10 OSK";
    24.  
    25. if( process ) {
    26. delete process;
    27. process = new QProcess(this);
    28. process->start(program, QStringList() << folder);
    29. }
    30. else {
    31. process = new QProcess(this);
    32. process->start(program, QStringList() << folder);
    33. }
    34. }
    35. else {
    36. qDebug() << "Windows pre-10 identified";
    37.  
    38. if( process ) delete process;
    39. process = new QProcess(this);
    40. process->start(program, QStringList() << tt);
    41. }
    42. #endif
    43. }
    44.  
    45. Keyboard::~Keyboard()
    46. {
    47. #ifdef WIN32
    48. if( process ) delete process;
    49. #endif
    50. }
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to hide virtual keyboard in Qt?

    I hope it gives you a little idea where I'm going wrong.
    No, not really. What you've posted is a constructor and destructor with a bunch of code that seem to have nothing to do with a virtual keyboard at all.

    Where did this Keyboard class come from? Did you write it? Did you download it from somewhere? How are you creating it? What do you see on screen?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  9. #9
    Join Date
    Sep 2017
    Posts
    29
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: How to hide virtual keyboard in Qt?

    Go find a book and learn.

  10. #10
    Join Date
    Sep 2016
    Location
    U.K.
    Posts
    16
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to hide virtual keyboard in Qt?

    Quote Originally Posted by GeneCode View Post
    Go find a book and learn.
    Thanks for the tip, you're too helpful !

  11. #11
    Join Date
    Aug 2015
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: How to hide virtual keyboard in Qt?

    zed220, the problem is that you didn't create a virtual keyboard object.

    You started an external application process that acts as a virtual keyboard.

    The only way to interact with such application is using the processId (e.g. sending signals) or using any specific implemented application interface (e.g. TCP socket, etc).
    In your case, the simplest way is sending a message to close the application using the menu Tools->exit, but don't ask me how ;-)

  12. The following user says thank you to VALE61 for this useful post:

    d_stranz (19th September 2017)

  13. #12
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to hide virtual keyboard in Qt?

    You started an external application process that acts as a virtual keyboard.
    Ah, this makes sense and it explains all the mysterious QProcess code in the constructor. There is a Qt Virtual Keyboard project that implements a plugin and QML UI for a multi-language virtual keyboard but I have not tried it.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Virtual keyboard example
    By Coder5546 in forum Newbie
    Replies: 1
    Last Post: 29th November 2014, 14:45
  2. Virtual Keyboard
    By NoRulez in forum Qt Programming
    Replies: 9
    Last Post: 5th August 2010, 08:02
  3. How to get the virtual keyboard?
    By ramesh.bs in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 2nd June 2010, 12:58
  4. like virtual keyboard?
    By triperzonak in forum Qt Programming
    Replies: 4
    Last Post: 10th July 2008, 17:42
  5. Virtual Keyboard
    By Micawber in forum Qt Programming
    Replies: 1
    Last Post: 3rd September 2007, 20:59

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.