Results 1 to 6 of 6

Thread: qtableview hide/disable icon (Qt::DecorationRole)

  1. #1
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default qtableview hide/disable icon (Qt::DecorationRole)

    Hello,
    I have a model (QStandardItemModel) that is used by 2 views. One of them is QTableView.
    In my model I have data with Qt::DecorationRole for icon's that are displayed in other view.

    The question: how to disable icons on QTableView (without delegates/subclass - I want to go simplistic here).

    Currently I did resolve this using setIconSize( QSize(0,0) ) but I don't know if view (QTableView) still query model for Qt::DecorationRole.

    My question also could be: is view, when is set setIconSize( QSize(0,0) ) to 0, query model for that item data roles?

    Best regards.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  2. #2
    Join Date
    Apr 2010
    Location
    Russian Federation, Kaluga
    Posts
    20
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qtableview hide/disable icon (Qt::DecorationRole)

    For disabling - Try to set disable flags (item->flags() & ~Qt::ItemIsEnabled) for needed item in your model through void QStandardItem::setFlags()
    For hidding icon - try to set empty icon ( QIcon()) for needed item through QStandardItem::setIcon().

  3. #3
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: qtableview hide/disable icon (Qt::DecorationRole)

    Yes, but there is a problem with that, because this model is used by 2 views, ListView (that display icons) and TableView (that don't display icons).
    So I can't modify model itself.

    And I don't want to disable item, I want to force QTabelView to ignore item data with Qt:ecorationRole (icons).
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: qtableview hide/disable icon (Qt::DecorationRole)

    You can use a proxymodel which filters the decoration role. Then set the original model as source. Thus you can use only one model with different viewing parameters.

  5. The following user says thank you to Lykurg for this useful post:

    Talei (13th November 2011)

  6. #5
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: qtableview hide/disable icon (Qt::DecorationRole)

    I thought about that but currently it's just initial implementation so I want to go minimalistic with this.

    And for educational reason:
    is view, when is set setIconSize( QSize(0,0) ) to 0, query model for that item data roles?
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  7. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: qtableview hide/disable icon (Qt::DecorationRole)

    As far as I can see yes: http://qt.gitorious.org/qt/qt/blobs/...te.cpp#line340
    It is called regardless the size is 0 or not.

  8. The following user says thank you to Lykurg for this useful post:

    Talei (14th November 2011)

Similar Threads

  1. how to hide icon of myapp in menu symbian
    By ngoanrazor in forum Newbie
    Replies: 3
    Last Post: 8th June 2011, 05:13
  2. Replies: 1
    Last Post: 15th October 2010, 22:30
  3. Replies: 5
    Last Post: 19th March 2010, 05:33
  4. How to hide an Icon?
    By Alex Snet in forum Qt Programming
    Replies: 0
    Last Post: 28th May 2009, 10:32
  5. How to Disable or hide cursor from QWidget?
    By ashukla in forum Qt Programming
    Replies: 5
    Last Post: 17th October 2007, 14:42

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.