Widgets style is not the same as my system's style
-
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:
And this is the output from "python main.py"
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())
-
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.
-
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.
@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? -
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.
-
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.
@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.
-
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.
-
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.
@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 -
With PySide2 ?
How did you install it ? -
@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
-
Even if you use a different style explicitly ?