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. QTreeWidget gird lines

QTreeWidget gird lines

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 443 Views
  • 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.
  • G Offline
    G Offline
    GaryT
    wrote on 4 Aug 2023, 15:53 last edited by
    #1

    I am new to QT and I am trying to figure out how to add gridlines to the sections of a QTreeWidget. From what I can see, it looks like you have to override the paintEvent() or maybe the QStyledItemDelegate. I have also seen references to using style sheets. I was wondering if there is a recommended way.

    Thanks in advance
    Gary

    J 1 Reply Last reply 4 Aug 2023, 19:03
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 4 Aug 2023, 18:38 last edited by
      #2

      Hi,

      I am unsure of the result you seek. Do you have an image of what you would like to obtain ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • G GaryT
        4 Aug 2023, 15:53

        I am new to QT and I am trying to figure out how to add gridlines to the sections of a QTreeWidget. From what I can see, it looks like you have to override the paintEvent() or maybe the QStyledItemDelegate. I have also seen references to using style sheets. I was wondering if there is a recommended way.

        Thanks in advance
        Gary

        J Offline
        J Offline
        JonB
        wrote on 4 Aug 2023, 19:03 last edited by
        #3

        @GaryT
        If you are happy with the CSS solution at https://stackoverflow.com/questions/33911102/qtreeview-grid-line-color

        QTreeView::item { border: 0.5px ; border-style: solid ; border-color: lightgray ;}
        

        that is the simplest. (A QTreeWidget is a QTreeView. Above should work for you, else try QTableWidget instead.) Read the comments there for a limitation.

        Otherwise @mrjj's code at https://forum.qt.io/topic/110101/how-to-create-grid-line-in-qtreewidget/6 shows a minimal delegate.

        G 1 Reply Last reply 5 Aug 2023, 01:40
        1
        • J JonB
          4 Aug 2023, 19:03

          @GaryT
          If you are happy with the CSS solution at https://stackoverflow.com/questions/33911102/qtreeview-grid-line-color

          QTreeView::item { border: 0.5px ; border-style: solid ; border-color: lightgray ;}
          

          that is the simplest. (A QTreeWidget is a QTreeView. Above should work for you, else try QTableWidget instead.) Read the comments there for a limitation.

          Otherwise @mrjj's code at https://forum.qt.io/topic/110101/how-to-create-grid-line-in-qtreewidget/6 shows a minimal delegate.

          G Offline
          G Offline
          GaryT
          wrote on 5 Aug 2023, 01:40 last edited by
          #4

          Thanks for all your help.

          Gary

          1 Reply Last reply
          0

          3/4

          4 Aug 2023, 19:03

          • Login

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