PDA

View Full Version : QInputDialog::getText - can't get access by keyboard



m_fighter
16th June 2010, 17:25
System: gentoo. Qt 4.6.2. Not using any display manager - just X server.

I try to get user input, but dialog doesn't react on keyboard, even can't close it by pressing Esc or Enter - only by mouse clicks.

Code:


bool ok;
QString pwd = QInputDialog::getText(this, NULL, tr("Password:"), QLineEdit::Password, "", &ok);
if( ok && !pwd.isEmpty() )
{
...
}


QApplication::focusWidget() remains parent of QInputDialog (guess it by logging) - is it common behavior?

tbscope
16th June 2010, 17:29
System: gentoo. Qt 4.6.2. Not using any display manager - just X server.

I try to get user input, but dialog doesn't react on keyboard,
You most likely posted the answer in your first line.
Is your system working correctly?





bool ok;
QString pwd = QInputDialog::getText(this, NULL, tr("Password:"), QLineEdit::Password, "", &ok);
if( ok && !pwd.isEmpty() )
{
...
}


QApplication::focusWidget() remains parent of QInputDialog (guess it by logging) - is it common behavior?

Do you mean that the mainwindow remains the parent of the input dialog? Then yes, that's by design and how you wrote your code.

m_fighter
17th June 2010, 05:50
Thanks for answering.


You most likely posted the answer in your first line.
Is your system working correctly?


Yes, it is. But may be it's not properly configured - I am working on it. Except this trouble everything works fine. It's a some kind of terminal - I don't need there Gnome or KDE. I set up auto-login, and when system boot - X server starts and run my program.



Do you mean that the mainwindow remains the parent of the input dialog? Then yes, that's by design and how you wrote your code.

No, sorry for my bad English.
I meant that the window which QApplication:: focusWidget () returned is the dialog parent (mainwindow). I expected that the QApplication:: focusWidget () will return a pointer to QInputDialog (because it is modal, and as my mind must have focus).
Mainwindow set as central widget in qApp. Keyboard works fine in any other place of program.
As I can see system uses policy "focus-follow-mouse" by default (I do not know where it is configured), but even when mouse over QInputDialog - it also doesn't react on keyboard.

Vankata
27th August 2010, 18:52
Hi m_fighter,
I have exactly the same problem using Qt 4.6.0, MSVS2005 on Windows Vista Ultimate x64. The strange thing is that if I create a new project and I use QInputDialog, it works correctly. In the already developed large application, the dialog doesn't update?!
Did you manage to find out what was wrong in your case?
Thanks!

Vankata
28th August 2010, 05:42
Solved! I installed Qt 4.6.3 and now everything is fine.