0

I designed a GUI in Qt Designer, making small adjustments and tuning the spacing to make it look somewhat decent. Unfortunately all that meticulous work pretty much went out the window when pyuic5 decided to send my GUI back to 2006. I think the images speak for themselves.

The desired appearance

GUI after it got beaten half to death with the ugly bat

I did use layouts, so all the proportions are pretty much correct, but for some reason the corners, lines, and (obviously) the color scheme are all wildly different. So somehow Qt Designer knows how to generate windows with the native look-and-feel, but PyQt5 can't do it or can't be bothered? Some people describe how to change the look manually, but if there's a way I can tell PyQt5 to always use the native appearance scheme, I would much rather do that.

The configuration of my working/testing environment is this:

  • Fedora 34 using default GNOME Desktop Environment
  • Miniconda3 with full Anaconda-2020.11 environment, PyQt 5.9 and utilizing pyuic5 from here
  • Qt Designer 5.15 installed via RPM repositories, with associated packages (qt5-qtbase-devel, qt5-qtwayland)
Keegs
  • 117
  • 5
  • 1
    This has got nothing to do with pyuic. I would guess (since you give very little relevant information) that the Qt libraries being used by Designer on your system aren't the same as the ones used by your PyQt installation. Presumably, you are using a widget-style plugin that the latter doesn't know about, so it's defaulting to the "fusion" style. What platform(s) are you testing on? Did you install PyQt5 via pip? How did you install Qt Designer? – ekhumoro Sep 25 '21 at 13:45
  • @ekhumoro This is true, PyQt5 is using the Qt libraries from the conda env, whereas Designer is using them from the system. I’ve added more information to the question. Thank you for letting me know what might be the root of this; it just didn’t occur to me there might be a more configuration-based problem instead of there being a style setting that wasn’t getting pulled correctly. – Keegs Sep 25 '21 at 17:40
  • Your question (and title/tags) should really mention conda, since that seems to be the most relevant factor. This isn't really a Qt/PyQt issue at all. You're using an IDE that deliberately creates a platform-agnostic environment. When conda runs your application, you it will see it just as some-random-user would see it. If you want to see how it looks on your own system, install the official Fedora PyQt packages and run it outside of conda. – ekhumoro Sep 25 '21 at 20:43
  • PS: PyQt-5.9 is pretty ancient. You really should upgrade it if you can. If not, you should probably ditch conda and start looking for a more suitable IDE ;-) – ekhumoro Sep 25 '21 at 21:25
  • I'm developing for a target system I know has Anaconda 2020.11, so I was trying to go with that. I'll check if it has system Qt/PyQt installed, but considering that configuration is RHEL7, I doubt the packages are much newer. In addition there are other Python libraries I will be attempting to leverage, and they will probably have requirements shipped from conda. Is there a way I can tell PyQt5 to use the system Qt libraries if they exist? Or a way I can tell python to check the system path for PyQt5 there instead? – Keegs Sep 26 '21 at 06:12
  • Ideally if there is a way to find and ship that "widget-style plugin" you mentioned in your first comment with my application, I'd like to know how to accomplish it. – Keegs Sep 26 '21 at 06:15
  • PyQt must always use the version of Qt it was compiled against. As for the widget-style, I would guess that your conda Qt only has the built-in "windows" and "fusion" styles. You can check it like this: `from PyQt5.QtWidgets import QStyleFactory; print(QStyleFactory.keys())`. You can also look in the Preview menu in Designer to see what your system Qt uses (presumably something like "gtk"). If you want that style in conda, you would have to install some alternative Qt/PyQt packages that have it. – ekhumoro Sep 26 '21 at 18:34
  • It might also be possible to compile the [qt-style-plugins](https://github.com/qt/qtstyleplugins) against your current conda Qt. But if your clients don't have the same version of Qt you have, they will have to do the same. (You really should file a bug report to the anaconda project asking them to fix their broken packages). – ekhumoro Sep 26 '21 at 19:15

0 Answers0