Results 1 to 5 of 5

Thread: How to get focus event in child widget

  1. #1
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default How to get focus event in child widget

    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
    Qt Code:
    1. Form:: Form (QWidget *parent)
    2. {
    3. ...
    4. listview1->setFocusProxy (this);
    5. listView2->setFocusProxy (this);
    6. ...
    7. }
    To copy to clipboard, switch view to plain text mode 
    and reimplement Form::focusInEvent (QFocusEvent * event) but it is not work, what I have to do for working ?

    Best regards,
    Yuriy Rusinov.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to get focus event in child widget

    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?

  3. #3
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: How to get focus event in child widget

    OK, I try to read setFocus and setFocusPolicy for more info, could you give me some examples for these functions applications. Thanks in advance.
    Best regards,
    Yuriy Rusinov.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to get focus event in child widget

    Do they really need such examples? I think the docs are clear on the subject.

  5. #5
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: How to get focus event in child widget

    Problem was solved by subclassing QListView and reimplementation focusInEvent handler. Thanks a lot.
    Best regards,
    Yuriy Rusinov.

Similar Threads

  1. When is the best time to delete a QCanvasItem
    By irudkin in forum Qt Programming
    Replies: 12
    Last Post: 8th March 2007, 21:28
  2. Replies: 5
    Last Post: 4th August 2006, 23:44
  3. minimize child widget
    By sreedhar in forum Qt Programming
    Replies: 5
    Last Post: 15th May 2006, 12:02
  4. Move child widget along with the parent widget
    By sreedhar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2006, 12:00
  5. Referencing Parent Widget from Child
    By taylor34 in forum Qt Programming
    Replies: 8
    Last Post: 11th April 2006, 15:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.