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. Breeze theme on python virtual environment

Breeze theme on python virtual environment

Scheduled Pinned Locked Moved Solved General and Desktop
pythonpyside6themes
2 Posts 1 Posters 58 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.
  • R Offline
    R Offline
    rtadd
    wrote last edited by rtadd
    #1

    Hello.
    I have just started using Qt through the PySide6 library in python. My pc is running debian 13 with the KDE desktop.

    I've created a virtual environment and installed the library there. The problem is that this setup doesn't recognise the breeze theme. Printing QStyleFactory.keys() only outputs ['Fusion', 'Windows'].

    I've read on other posts that installing the library through the system package manager (apt in this case) solves this problem. And it did.

    However I'm still interested in trying to make it work in the virtual environment.

    Since the "apt" version of pyside was recognising the theme, I tried to find where the theme was located. The output of the "app.libraryPaths()" method was ['/usr/lib/x86_64-linux-gnu/qt6/plugins', '/usr/bin']

    From there I tried two different things:

    • First: using app.addLibraryPath() with both outputs worked in the sense that now the QStyleFactory.keys() method outputs ['Breeze', 'Windows', 'Fusion']. However, using app.setStyle('Breeze') doesn't seem to work and the app still uses the Fusion theme.

    • Second: used the "app.libraryPaths()" on the version in the virtual environment resulting in ['/home/.../venv/lib/python3.13/site-packages/PySide6/Qt/plugins', '/usr/bin'] and then tried to copy the theme from '/usr/lib/x86_64-linux-gnu/qt6/plugins'. The problem I had with this method is that I don't think there is only one file or folder that contains the whole theme. Copying the styles folder made it so that now 'Breeze' shows up when printing QStyleFactory.keys() and it changes the look of the app, but it is not the same as the rest of the OS.

    Here is an example of the app that I'm trying to run:

    class Window(QMainWindow):
    
        def __init__(self):
            super().__init__()
    
            self.setWindowTitle('App')
    
            self.container = QWidget()
            self.setCentralWidget(self.container)
            self.main_layout = QGridLayout(self.container)
    
            self.button = QPushButton(
                'Button'
            )
    
            self.combobox = QComboBox()
            self.combobox.addItems(['One', 'Two', 'Three', 'Four'])
    
            self.lineedit = QLineEdit()
    
            self.container_checbox = QWidget()
            self.checkbox_layout = QHBoxLayout(self.container_checbox)
    
            self.checkbox1 = QCheckBox('A')
            self.checkbox2 = QCheckBox('B')
            self.checkbox3 = QCheckBox('C')
            
            self.checkbox_layout.addWidget(self.checkbox1, alignment=Qt.AlignmentFlag.AlignHCenter)
            self.checkbox_layout.addWidget(self.checkbox2, alignment=Qt.AlignmentFlag.AlignHCenter)
            self.checkbox_layout.addWidget(self.checkbox3, alignment=Qt.AlignmentFlag.AlignHCenter)
    
            self.slider = QSlider(Qt.Orientation.Horizontal)
            self.slider.setRange(0, 100)
    
            self.main_layout.addWidget(self.button, 0, 0)
            self.main_layout.addWidget(self.combobox, 0, 1)
            self.main_layout.addWidget(self.lineedit, 1, 0, 1, -1)
            self.main_layout.addWidget(self.container_checbox, 2, 0, 1, -1)
            self.main_layout.addWidget(self.slider, 3, 0, 1, -1)
    
    
    app = QApplication(sys.argv)
    print(app.libraryPaths())
    
    app.addLibraryPath("/usr/lib/x86_64-linux-gnu/qt6/plugins")
    # app.addLibraryPath("/usr/bin")
    print(QStyleFactory.keys())
    app.setStyle('Breeze')
    
    window = Window()
    window.show()
    
    app.exec()
    

    Have I missed something? An additional command on the first try or some other folder on the second? Has this been resolved with some other method? Because I couldn't find a solution on the web?

    Thanks

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rtadd
      wrote last edited by
      #2

      I've figured it out.
      It was a mismatch between the versions of Qt/Pyside6, not exactly sure which one.
      Checking with

      print("PySide6: v", PySide6.__version__)
      

      I found out that the version that I installed in the virtual environment was newer (6.10.1) that the version available though apt (6.8.2.1).

      Maybe it was a bit excessive, but I deleted the virtual environment and created a new one in which I installed the same version of pyside6 that is available through the distro package manager (6.8.2.1).

      Adding this line enabled the selection of the breeze theme, the same as before.

      app.addLibraryPath("/usr/lib/x86_64-linux-gnu/qt6/plugins")
      

      The difference now is that when I use the "app.setStyle('Breeze')" command, it works.

      Hope this is useful for someone.

      1 Reply Last reply
      0
      • R rtadd has marked this topic as solved

      • Login

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