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. Widgets style is not the same as my system's style

Widgets style is not the same as my system's style

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 2 Posters 1.2k 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.
  • O Offline
    O Offline
    Oskar der Grosse
    wrote on last edited by
    #1

    Hi, i'm trying to create an app for linux desktop and chose QtWidgets for it. In QtDesigner, widgets look how they should be which is Lightly i'm currently using. But when i try to preview GUI from terminal using "python main.py", widgets are not looking like my system's style. I use KDE Plasma and have another styles too like Breeze and Oxygen. I see only two styles, Windows and Fusion as a result of print(QStyleFactory.keys()). But QtDesigner knows what styles i have and presents me all of styles i have like Breeze Style, Windows Style, Fusion Style, Lightly Style. I'm trying to make widgets look like system's default style do you know how do i do it?
    This is the preview from QtDesigner:
    Screenshot_20211027_202317.png
    And this is the output from "python main.py"
    Screenshot_20211027_202241.png
    The codes in main.py are:

    import sys
    from PySide6.QtWidgets import *
    from PySide6.QtCore import QFile
    from ui_mainwindow import Ui_MainWindow
    from qtstyles import StylePicker
    
    print(QStyleFactory.keys())
    
    class MainWindow(QMainWindow):
        def __init__(self):
            super(MainWindow, self).__init__()
            self.ui = Ui_MainWindow()
            self.ui.setupUi(self)
    
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        app.setStyle('Lightly')
      # app.setStyle("Default')
      # app.setStyle("Breeze')
        window = MainWindow()
        window.show()
    
        sys.exit(app.exec())
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Is it a pip installed PySide6 ?

      If so, it likely does not look into your system as it does not use your distribution provided Qt.

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

      O 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        Is it a pip installed PySide6 ?

        If so, it likely does not look into your system as it does not use your distribution provided Qt.

        O Offline
        O Offline
        Oskar der Grosse
        wrote on last edited by
        #3

        @SGaist I uninstalled the PySide6 with doing "pip uninstall PySide6" and installed from my distribution's repositories but this didn't work. I also redone "uic -g python mainwindow.ui > ui_mainwindow.py", nothing changed, i still see Windows and Fusion as a result of print(QStyleFactory.keys()).
        My project folder is located in my Documents folder, should i move project folder somewhere else?

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

          Can you start your script with the QT_DEBUG_PLUGINS environment variable set to 1 ?

          This is to see what happens on the plugin side.

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

          O 1 Reply Last reply
          0
          • SGaistS SGaist

            Can you start your script with the QT_DEBUG_PLUGINS environment variable set to 1 ?

            This is to see what happens on the plugin side.

            O Offline
            O Offline
            Oskar der Grosse
            wrote on last edited by
            #5

            @SGaist Setting QT_DEBUG_PLUGINS environment variable to 1 did show nothing to me or i was looking wrong place, i'm a bit cursed at things like this. But thank you so much for taking the time for me. I tried using PyQt5 instead of PySide6 and this worked pretty good. Now i can see every styles that my system has and the GUI is just looks like native. Thank you again.

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

              Which distribution are you using ?

              Wait... I just realized, PySide6 uses Qt 6 however your system is likely still on Qt 5 hence your issue.

              Would you mind trying PySide2 ? I guess it should work as well as PyQt5 in that regard.

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

              O 1 Reply Last reply
              0
              • SGaistS SGaist

                Which distribution are you using ?

                Wait... I just realized, PySide6 uses Qt 6 however your system is likely still on Qt 5 hence your issue.

                Would you mind trying PySide2 ? I guess it should work as well as PyQt5 in that regard.

                O Offline
                O Offline
                Oskar der Grosse
                wrote on last edited by Oskar der Grosse
                #7

                @SGaist im having an another error which is "ImportError: libshiboken2.abi3.so.5.15: cannot open shared object file: No such file or directory" so i didnt even give it a try
                i use manjaro kde

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

                  With PySide2 ?
                  How did you install it ?

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

                  O 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    With PySide2 ?
                    How did you install it ?

                    O Offline
                    O Offline
                    Oskar der Grosse
                    wrote on last edited by
                    #9

                    @SGaist i have installed it with pip now installed from my distribution's repositories i dont get that error anymore but widgets styles are still fusion

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

                      Even if you use a different style explicitly ?

                      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

                      • Login

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