Results 1 to 4 of 4

Thread: QItemDelegates and currentItem

Hybrid View

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

    Default Re: QItemDelegates and currentItem

    Qt Code:
    1. // focus
    2. if (option.state & QStyle::State_HasFocus)
    3. {
    4. ...
    5. }
    6.  
    7. // selection
    8. if (option.state & QStyle::State_Selected)
    9. {
    10. ...
    11. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  2. #2
    Join Date
    Sep 2007
    Location
    Szczecin, Poland
    Posts
    153
    Thanks
    7
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QItemDelegates and currentItem

    Tried, but Has_Focus is set only when item is current and view has focus and i need to draw current item different even if view have no focus so this state is rather useless.
    Any other ideas?

    I thought about setting ModelIndex in delegate when current changes but it doesn't fits to typical delegates usage and i'm not sure if i want to implement such workarounds.
    See GrEEn (Graphics Effects Environment)
    http://sourceforge.net/project/platf...roup_id=232746
    a qt-based plugins oriented MDI image processing application(contains also qt plugins like styles & imageformats).

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

    Default Re: QItemDelegates and currentItem

    I'd suggest using QPersistentModelIndex if you decide to store an index. An ugly but quite common workaround to deliver information from view to delegate is to assume that the view is parent of the delegate. This way you can also easily check if
    Qt Code:
    1. QAbstractItemView* view = dynamic_cast<QAbstractItemView*>(parent());
    2. if (view && view->currentIndex() == index)
    3. option.state |= QStyle::State_HasFocus;
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

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.