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. Styling a QTreeWidget
Qt 6.11 is out! See what's new in the release blog

Styling a QTreeWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 3.4k 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.
  • C Offline
    C Offline
    Chrisw01
    wrote on last edited by
    #1

    Hello everyone.

    I'm trying to style a QtreeWidget with the following code

    QString treeWidgetStyle("QTreeWidget { border: 1.5px solid gray; border-radius: 9px; background-color: palette(base); } ");
    ui->treeWidget->setStyleSheet(treeWidgetStyle);
    
    

    my problem is, the header top right and top left are expanding past the radius corners. How would stylesheet the top left and top right corner of the header. I am sorry, I cannot figure out how to attach a image to show.

    Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      How to insert image on this forum guid

      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
      • C Offline
        C Offline
        Chrisw01
        wrote on last edited by
        #3

        Thanks, here's the image, notice the top left and right corners of the header is not within the radius, I'm sure it can be styled somehow I would think.

        alt text

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

          http://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qheaderview you basically have to set the radius to the headerview too

          "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
          • C Offline
            C Offline
            Chrisw01
            wrote on last edited by
            #5

            Hi, and thanks for all your help. I've tried styling which does work however it still produces undesirable results. I have found this on the net..

            Problem with QHeaderView Border Radius but don't understand what his fix is.

            I have the same result, the border has a radius however the whitespace behind it is still drawn outside of this radius.

            1 Reply Last reply
            0

            • Login

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