PDA

View Full Version : How to get focus event in child widget



YuriyRusinov
13th October 2006, 14:30
Hello, All !

I have a form with many childs in layouts. I have to get focus event for 2 QListView * objects of them using event handlers for main form only ? These objects are situated in multilevel layouts and its subclassing is not desirable, because the form will be segmentation fault dropped. I tried


Form:: Form (QWidget *parent)
{
...
listview1->setFocusProxy (this);
listView2->setFocusProxy (this);
...
}

and reimplement Form::focusInEvent (QFocusEvent * event) but it is not work, what I have to do for working ?

Best regards,
Yuriy Rusinov.

wysota
13th October 2006, 21:08
I don't know if I understand correctly, but you're surely using the focus proxy in the wrong way. It is used to forward the focus from the calling widget to the widget used as the argument of the QWidget::setFocusProxy call. I suggest you read the docs for more info. As for your problem - how about just calling QWidget::setFocus to set the focus? Why do you need such a construction anyway?

YuriyRusinov
16th October 2006, 09:23
OK, I try to read setFocus and setFocusPolicy for more info, could you give me some examples for these functions applications. Thanks in advance.

wysota
16th October 2006, 09:30
Do they really need such examples? I think the docs are clear on the subject.

YuriyRusinov
17th October 2006, 08:53
Problem was solved by subclassing QListView and reimplementation focusInEvent handler. Thanks a lot.