PDA

View Full Version : focus issue



samirg
1st September 2007, 02:10
Dear folks,

I have several threads running in sequence, each thread creates new QDialog object, and
closes/hides this dialog object when thread finishes.

Each time a QDialog object is created and displayed by thread, this dialog object takes away editing 'focus' from me/user.

e.g., 10 threads are running, and at same time I am editing a document. It interrupts me 9
times. I have to grab focus back from QDialog 9 times while I am editing, and it is very annoying. I don't want QDialog to take away focus from me while I am editing.

I looked at some previous discussions and tried to set focusPolicy as
setFocusPolicy(qt.QWidget.ClickFocus)

such that, QDialog widow/widget should grab focus only when I click this widget otherwise not. However, it does not work. I don't know why.

regards,

marcel
1st September 2007, 02:29
First of all, you must not create widgets from other threads. There are other ways to do this - have the worker threads tell the GUI thread create them.

Second of all, if the dialogs are not modal, you can create an event filter for them and when they become visible, you transfer the focus to your widget.