Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Setting style on QTreeWidget root items (PyQT)
Qt 6.12 LTS is out! See what's new in the release blog

Setting style on QTreeWidget root items (PyQT)

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 969 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.
  • J Offline
    J Offline
    jspeirs
    wrote on last edited by
    #1

    Is there a way to set a style for only the root items in a QTreeWidget?

    For example if below is my tree, I'd like to set a style on just the "/bob" and "/tom" items.

    /bob
         /photos
         /documents
    /tom
        /photos
        /documents
    

    I tried this and a few other variations with no luck:

    TREE_STYLESHEET = """
        QTreeView::item:first  {
            background-color: red;
        }
    """
    self.MyTreeWidget.setStyleSheet(TREE_STYLESHEET)
    

    I've been looking here:

    http://doc.qt.io/qt-5/stylesheet-reference.html

    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
    • Unsolved