Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. PySide2 QToolButton stylesheets
Qt 6.11 is out! See what's new in the release blog

PySide2 QToolButton stylesheets

Scheduled Pinned Locked Moved Solved Language Bindings
2 Posts 1 Posters 1.1k 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.
  • I Offline
    I Offline
    iLLiCiT
    wrote on last edited by
    #1

    Hi, I've question about stylesheets of QToolButton and different popupMenu property values. Because it seems that PySide2 store popupMenu property as object so (for example) this stylesheet is ignored:

    QToolButton[popupMenu="1"] {
        padding-right: 20px;
    }
    

    Python part:

    tool_btn = QtWidgets.QToolButton()
    tool_btn.setText("Test")
    
    tool_menu = QtWidgets.QMenu(tool_btn)
    
    tool_btn.setMenu(toolmenu)
    tool_btn.setPopupMode(QtWidgets.QToolButton.MenuButtonPopup)
    

    I've fake it using custom property but that's not ideal as I want to use it as global stylesheet which should be applied on any widgets outside of my project.

    # Set custom propert name
    tool_btn.setProperty("popup_menu", "1")
    
    /* Both properties with same stylesheet */
    QToolButton[popupMenu="1"], QToolButton[popup_menu="1"] {
        padding-right: 20px;
    }
    

    Has anybody idea how it's doable?

    Using: Python 3.7.6, PySide2 5.15.2

    1 Reply Last reply
    0
    • I Offline
      I Offline
      iLLiCiT
      wrote on last edited by
      #2

      Ok so I found out that I had to use MenuButtonPopup as value

      QToolButton[popupMode="MenuButtonPopup"] {
          padding-right: 20px;
      }
      
      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