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. #1
    Join Date
    May 2006
    Posts
    7
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

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

    Hi,

    I'm having difficulty selecting an item and drawing a focus rect on it at the same time.

    What I want to do is: in a single-selection mode tree widget if the last selected item does not pass a test when the user clicks a different item I want to move the selection & focus rect back to the last selected item. The last item can be re-selected without problem, however, the focus rect always seems to stay on the item the user just clicked.

    Please help if any of you has done this before.

    Qt Code:
    1. void MyForm::OnTreeWidgetItemSelectionChangedSlot()
    2. {
    3. . . .
    4.  
    5. //TreeWidget has single selection mode.
    6. //This slot is in response to the itemSelectionChanged signal.
    7.  
    8. SelectedItemList = TreeWidget->selectedItems();
    9.  
    10. if (SelectedItemList.count() > 0)
    11. {
    12. //Get the newly selected item.
    13. Item = SelectedItemList[0];
    14.  
    15. if (LastItem failed the validation test)
    16. {
    17. //Unselect the newly selected item.
    18. Item->setSelected(false);
    19.  
    20. //Set the selection & focus back to the last item.
    21. LastItem->setSelected(true);
    22. TreeWidget->setCurrentItem(LastItem);
    23. }
    24. else
    25. {
    26. LastItem = Item;
    27. ...
    28. }
    29. }
    30. }
    To copy to clipboard, switch view to plain text mode 

    Thanks,
    TM
    Last edited by wysota; 6th November 2006 at 17:48. Reason: missing [code] tags

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.