Hi all,
I have a Keyboard that shall be opened, when I tap a QLineEdit on a touch screen.
This works fine, but the problem is that the Keyboard is some kind of not Focussed, when I open it a second and/or a third time. So I have to tap on the Keyboard first and then it handles my inputs.
My Code:
main.cpp:
screenLogin
::screenLogin(QWidget *parent
) : ui(new Ui::screenLogin)
{
ui->setupUi(this);
keyboardlogin = new Keyboard(this); // Keyboard is set to private in .h-file
keyboardlogin->close(); // have to close it here, because it opens automatically
QObject::connect(ui
->editFieldPassword,
SIGNAL(selectionChanged
()), keyboardlogin,
SLOT(runKeyboard
()));
main.cpp:
screenLogin::screenLogin(QWidget *parent) :
QWidget(parent),
ui(new Ui::screenLogin)
{
ui->setupUi(this);
keyboardlogin = new Keyboard(this); // Keyboard is set to private in .h-file
keyboardlogin->close(); // have to close it here, because it opens automatically
QObject::connect(ui->editFieldPassword,SIGNAL(selectionChanged()), keyboardlogin,SLOT(runKeyboard()));
To copy to clipboard, switch view to plain text mode
Keyboard.cpp:
void Keyboard::runKeyboard()
{
qDebug() << "KeyboardVisible?" << isVisible() << isActiveWindow();
if(!ALREADY_OPEN){
ALREADY_OPEN = true;
line->deselect();
setLineEdit(line);
this->keyboardCaller = line->objectName();
this->keyboard_ui->lineEdit->setText(line->text());
outputText = "";
currentCursorPos = line->text().length();
outputText = line->text();
this->keyboard_ui->lblMinMax->setVisible(false);
this->setWindowModality(Qt::ApplicationModal);
this->setWindowFlags(Qt::SplashScreen);
this->show();
// this->setFocus();
qDebug
() <<
"KeyboardVisible2?" << isVisible
() <<
QApplication::activeWindow();
}
}
void Keyboard::runKeyboard()
{
qDebug() << "KeyboardVisible?" << isVisible() << isActiveWindow();
if(!ALREADY_OPEN){
ALREADY_OPEN = true;
QLineEdit *line = (QLineEdit *)sender();
line->deselect();
setLineEdit(line);
this->keyboardCaller = line->objectName();
this->keyboard_ui->lineEdit->setText(line->text());
outputText = "";
currentCursorPos = line->text().length();
outputText = line->text();
this->keyboard_ui->lblMinMax->setVisible(false);
this->setWindowModality(Qt::ApplicationModal);
this->setWindowFlags(Qt::SplashScreen);
this->show();
// this->setFocus();
qDebug() << "KeyboardVisible2?" << isVisible() << QApplication::activeWindow();
}
}
To copy to clipboard, switch view to plain text mode
Does anyone know what I am doing wrong?
Thanks.
Bookmarks