Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Setting icon to each items head
Forum Updated to NodeBB v4.3 + New Features

Setting icon to each items head

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    ShinSat
    wrote on last edited by ShinSat
    #1

    Hi All,

    Now I'm implementing QTreeView with QStandardItem(Model).
    Does anybody know if I can set an icon to the head of each item(row), instead of the default up/down arrow?

    Many thanks in advance for your update!
    Regards,
    Sat

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      http://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtreeview

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      S 1 Reply Last reply
      1
      • VRoninV VRonin

        http://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtreeview

        S Offline
        S Offline
        ShinSat
        wrote on last edited by
        #3

        @VRonin Thanks for an update!
        Yes, I'm reading it right now!
        I want to switch the icon from multiple icon list according to the contents.
        SO,,,,, I need to program to switch the stylesheet (eg.QTreeView::branch:open/close), correct?
        Not sure any alternative solution at the moment..

        Sat

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          Are you sure you can't work with just the Qt::DecorationRole? what you want to implement is not easy at all.

          Either you subclass a style and reimplement drawPrimitive for QStyle::PE_IndicatorBranch or use the stylesheet to remove the indicators altogether and paint them over manually subclassing QTreeView and reimplementing drawBranches

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved