PDA

View Full Version : How to get QWidget as Child-Popup as active Window?



nernst
4th December 2015, 06:45
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) :
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()));


Keyboard.cpp:


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();
}
}

Does anyone know what I am doing wrong?

Thanks.