1

I am writing PySide tools that run within other 3rd party applications. The same tool will run in multiple applications and should be styled consistently across these. The problem I have is, these applications are sometimes using QT themselves and have their own styling, using presumably QPalette. When my tools parent to the main application they take on the main applications styling.

So I tried to solve this by using my own QPalette and setting my tools main window\widget to use it, however this doesn't have any effect on the widgets children and they still assume the styling from the main application (not sure if this is correct behaviour).

So I started using a stylesheet to customise the whole look, and largely this works. However it is still not consistent across applications. So either I am not overriding enough of the style sheet parameters or there are some things I cannot fix using the style sheet alone. Example of same style sheet in Nuke and 3ds Max

The very basic stylesheet I used in the test:

QWidget {
    margin: 0px;
    padding: 0px;
    spacing: 0px;
    color:white;
}

My Concise Questions are:

  1. Is it possible to completely override the appearance given by the QPalette using stylesheet alone?
  2. If it is and its relevant here, what could I be missing, the spacing\size are different. Both windows are at their minimum size. Other than margin and padding, I can't think what would be effecting it.

note: I know I haven't overwritten the QGroupbox style sheet, and even doing so doesn't produce the same result. I have also tried using em, px and ex. PySide version is 1.0.9 in nuke and 1.2.2 in max, if this makes a difference, and I guess it probably could. Thanks

1 Answers1

1

Unfortunately, due to historical reasons Qt does offer all too many ways to skin the same cat when it comes to widget styling, and the stylesheets don't affect layouts. Thus you can't describe an application's style completely using only QSS, and unless you're careful in your design, you'll end up styling things in all sorts of ways, especially if your code has a lot of history. That'll be the case with the tool you're building your plug-in for.

First and foremost, you've realized now that consistent styling is really an interface that all components must adhere to. If this interface is not specified in the plugin developer documentation for the plugin host application, it'll be ugly and unnecessarily hard.

The best you can do is iterate the application's other widgets and sniff their pallettes, layout spacings, etc. You'll basically have to hack it into a working shape, and hope that the next release of the host application doesn't break it. Since they don't specify anything in this respect, they themselves have nothing to test against nor develop against, so the expectation is that yes, it'll break, and yes, it'll be ugly. That's what you get when interface specification is ignored.

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
  • Thank you, its good to know., saves me wasting time trying to achieve the impossible with the stylesheet. I will maybe have to find a way of making the style sheet easily adjustable for different applications. – Philip Scadding Sep 13 '16 at 14:28
  • @Kuba Ober What is best source for learning qt for a complete beginner? – Sumeet Sep 15 '16 at 11:50
  • Example code and documentation. Make sure you can open any of Qt's examples and build it. It's then easy to experiment, change things, etc. Also get used to a version control system, e.g. git with smartgit GUI. Get in the habit of adding all of the code you work on to the repository, so that you can easily monitor your changes. – Kuba hasn't forgotten Monica Sep 15 '16 at 13:01