Results 1 to 1 of 1

Thread: problem with setFocus( Qt::MouseFocusReason )

  1. #1
    Join Date
    Sep 2009
    Posts
    15
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default problem with setFocus( Qt::MouseFocusReason )

    Has anyone noticed a problem with setFocus in 4.6.2. I've got a couple of lines of code that were working in our previous version of Qt. (4.4)

    I have a fairly simple dialog with two widgets (both derived from QListView) After a user action in listView_2 I call setFocus in order to switch the focus back to listView_1. The intention being to give listView_1 keyboard focus. However, I'm now finding that this is no longer working.

    in setupUI:

    Qt Code:
    1. listView_1 = new QListView( this );
    2. listView_1->setFocusPolicy( Qt:NoFocus );
    3.  
    4.  
    5. listView_2 = new QListView( this );
    6. listView_2->setFocusPolicy( Qt:NoFocus );
    To copy to clipboard, switch view to plain text mode 

    in my slot I call

    Qt Code:
    1. listView_1->setFocus( Qt::MouseFocusReason );
    To copy to clipboard, switch view to plain text mode 


    listView_1 never shows that it has focus. When I hit the arrow key to traverse the items in the list nothing happens. But if I hit the tab key until listView_1 gets focus then things work as expected.

    Has anyone else run into this? Am I using the setFocus method incorrectly? Have I missed something?

    Thanks.

  2. The following user says thank you to winkle99 for this useful post:

    hakermania (6th September 2011)

Similar Threads

  1. How to setFocus to QMenuBar programatically?
    By ticvitanic in forum Qt Programming
    Replies: 0
    Last Post: 2nd July 2010, 15:58
  2. setFocus() on Lineedit
    By qtuser20 in forum Qt Programming
    Replies: 1
    Last Post: 26th February 2010, 18:54
  3. setFocus problem
    By roxton in forum Qt Programming
    Replies: 3
    Last Post: 12th February 2009, 05:41
  4. QLineEdit setFocus
    By bunjee in forum Qt Programming
    Replies: 4
    Last Post: 24th April 2008, 16:22
  5. setfocus working?
    By mahe2310 in forum Qt Programming
    Replies: 8
    Last Post: 10th March 2006, 02:45

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.