ruby - Display an icon before text in a QTreeView -
i'm using qtruby qt 4.8.6 , trying create tree view each item has custom icon between tree controls , name. end result should this:
i getting space allocated icon should go, i'm not seeing icons. have them show up?
here's code (simplified remove no-data border cases):
class="lang-ruby prettyprint-override">class mymodel < qt::abstractitemmodel # ... def data(index, role) case role when qt::displayrole case index.column when 0; qt::variant.new(index.internalpointer.displayname) when 1; qt::variant.new(index.internalpointer.displaytype) end when qt::decorationrole if index.column==0 # testing show static icon items qt::pixmap.new(':/resources/images/objects-scene-normal.png') end end end end @mytreeview.model = mymodel.new
if want inspect qt designer .ui
file (in case tree view needs have property set have not) can seen here.
i think image cannot found path specified. verify qfileinfo::exists().
ruby qt treeview qtreeview qtruby
No comments:
Post a Comment