How to hide virtual keyboard in Qt?
Hi all,
I have a very simple code to start/show the virtual keyboard which works fine
Code:
keyboard = new Keyboard(this);
but I can not hide it dynamically I have tried
Code:
keyboard->disconnect();
also this
Code:
keyboard->deleteLater();
Has anyone got any suggestions please.
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).
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 ?
Re: How to hide virtual keyboard in Qt?
Quote:
'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.
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 ?
Re: How to hide virtual keyboard in Qt?
Quote:
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?
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.
Code:
#include "keyboard.h"
#include <QProcess>
#ifdef WIN32
#include <windows.h>
#include <QString>
#include <QStringList>
#include <QDebug>
#endif
#include "entrysettings.h"
{
#ifdef WIN32
QString folder
= "C:\\Windows\\System32\\osk.exe";
QString tt
= "C:\\Progra~1\\Common~1\\micros~1\\ink\\TabTip.exe";
if( EntrySettings::windowsMajorVersion() >= 10 ) {
qDebug() << "Setting Win 10 OSK";
if( process ) {
delete process;
}
else {
}
}
else {
qDebug() << "Windows pre-10 identified";
if( process ) delete process;
}
#endif
}
Keyboard::~Keyboard()
{
#ifdef WIN32
if( process ) delete process;
#endif
}
Re: How to hide virtual keyboard in Qt?
Quote:
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?
Re: How to hide virtual keyboard in Qt?
Go find a book and learn.
Re: How to hide virtual keyboard in Qt?
Quote:
Originally Posted by
GeneCode
Go find a book and learn.
Thanks for the tip, you're too helpful !
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 ;-)
Re: How to hide virtual keyboard in Qt?
Quote:
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.