Results 1 to 3 of 3

Thread: How to show/draw focus & select at the same time

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: How to show/draw focus & select at the same time

    QAbstractItemView behaves so that when a mouse press event is received, the selection is applied first and then the current index is set afterwards changing the selection. So by the time selection change is informed through signal, QAbstractItemView has not yet set the current index. So what happens here is that still if you change the current item to something else, QAbstractItemView comes and resets it back to the pressed index.

    One idea to solve this would be to delay the changing of the current item:
    Qt Code:
    1. // A QTimer with a timeout interval of 0 will time out as soon as all the events in the window system's event queue have been processed
    2. QTimer::singleShot(0, this, SLOT(setLastItemCurrent()));
    3.  
    4. void MyForm::setLastItemCurrent()
    5. {
    6. // get "LastItem" somehow or store is as a member variable or something..
    7. TreeWidget->setCurrentItem(LastItem);
    8. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

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

    tanminh (6th November 2006)

Similar Threads

  1. Tab/Enter focus problem
    By b1 in forum Qt Programming
    Replies: 4
    Last Post: 23rd October 2006, 23:34
  2. Problem with pointers while using localtime() and time()
    By jamadagni in forum General Programming
    Replies: 7
    Last Post: 11th January 2006, 15:48

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
  •  
Qt is a trademark of The Qt Company.