PDA

View Full Version : setFocus() on Lineedit



qtuser20
26th February 2010, 16:56
Hi

I have a QTableWidget , over which when the user presses an alphabet , a QDialog opens. The QDialog contains a lineedit .The user entered text is carried over to the lineedit but the tablewidget item remains highlighted.

I would like the focus to be set on the next lineedit in the second cursor position.

I have tried using setfocuspolicy(QT::Strongfocus) on the lineedit and also call the setfocus().But it does not help. The only solution that works is using activatewindow().However this has a downside, when i switch to different application without clicking outside in my current application, the dialog remains in the forefront.

Is there a better way than using activatewindow(), or how can i detect that a different application is now active and close the dialog (given that the user does not click outside)

Thankyou

yodasoda
26th February 2010, 18:54
just do:

QWidget->close();
QWidget->Show();


works for me.