Results 1 to 3 of 3

Thread: styling focus rect in QTreeView

  1. #1
    Join Date
    Apr 2008
    Posts
    104
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default styling focus rect in QTreeView

    Hello! I need an advice
    Is there a way to change the view of focus rect (dotted) around the active row? I have a descendant of QTreeView with the multiseleciton, custom drawRow() and reimplemented keyboard handling. I need to make a good visible current row (not the active item), but I cannot find how to do that right. Yes, I can change the font color/height via QStyleOptionViewItem in drawRow. And that's all. I cannot define the custom background, I cannot change the focus rect around the current row.
    item:selected:active is not the solution because I have many items selected and the "current cursor position" is the current item (currentIndex()) that is not selected by default in my QTreeView subclass.

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


  3. #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: styling focus rect in QTreeView

    Quote Originally Posted by roxton View Post
    Is there a way to change the view of focus rect (dotted) around the active row?
    Yes.
    but I cannot find how to do that right.
    Either have a custom delegate or use style-sheets.

    item:selected:active is not the solution because I have many items selected and the "current cursor position" is the current item (currentIndex()) that is not selected by default in my QTreeView subclass.
    That's ::item:active, isn't it?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. The following 2 users say thank you to wysota for this useful post:

    maverick (31st May 2013)

  5. #3
    Join Date
    Apr 2008
    Posts
    104
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: styling focus rect in QTreeView

    Quote Originally Posted by wysota View Post
    That's ::item:active, isn't it?
    Unfortunately, item:active affects all rows in QTreeView (I don't know why its happen). For example:

    MyTreeView::item:active {background-color: blue;}

    With such style, all rows will have blue background, and current row has the default white background.
    So, as you suggets, I will look to the item delegation.

  6. The following user says thank you to roxton for this useful post:


Similar Threads

  1. styling controls inside QTreeView
    By mentalmushroom in forum Qt Programming
    Replies: 2
    Last Post: 27th May 2011, 19:25
  2. Replies: 0
    Last Post: 1st November 2010, 09:22
  3. QTreeView does not get focus on S60
    By hubbobubbo in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 1st June 2010, 15:44
  4. Replies: 2
    Last Post: 2nd November 2009, 14:24
  5. Focus rect not drawing
    By draftpunk in forum Qt Programming
    Replies: 3
    Last Post: 11th November 2008, 16:21

Tags for this Thread

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.