2

I am developing my Python app with PyQt4 and I want to customize my app interface (QMainWindow, QLineEdit and so forth) in windows like this view (or something else):

enter image description here

Instead of this (default style on Windows 10):

enter image description here

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
IMAN4K
  • 1,265
  • 3
  • 24
  • 42
  • Do you know about QSS stylesheets? Also you could be a bit more specific about the decorations you want to have. Probably not everything is possible (especially with window frames). – NoDataDumpNoContribution Nov 19 '15 at 13:04
  • You cannot change the appearance of the existing titlebar (other than showing/hiding buttons), because that is controlled by the window-manager. – ekhumoro Nov 19 '15 at 15:45
  • @ekhumoro so how the telegram desktop developers did that with qt? https://github.com/telegramdesktop/tdesktop – IMAN4K Nov 20 '15 at 15:41
  • @Trilarion there are some bundled and limit style with QSS but what about for a complete different style like the first one i mentioned? – IMAN4K Nov 20 '15 at 16:12
  • They didn't: [you can't change the appearance of the titlebar that is provided by the window manager](http://stackoverflow.com/q/4507864/984421). The only work-around is to hide the existing titlebar and add a fake one, [like this](http://stackoverflow.com/a/10712258/984421). – ekhumoro Nov 20 '15 at 16:22

1 Answers1

1

For all styles except the window frame border use Qt stylesheets (QSS) (Documentation).

For the frame borders it's a bit difficult:

See the Qt window flags example to see what Qt can do with the window frame.

Basically you cannot style the window frame (they take the style from the OS), but you can hide/show buttons and you can show the window completely frameless.

On Windows however, some people hacked into the windows frame bar (Tabs in title bar: what's the secret?). This may be possible to do with Python too.

The most universal approach would be (although this is a bit costly) to not using any OS provided frame (Qt::CustomizeWindowHint) and then inside implement your own styled frame implemented drag and drop of the title bar and border and so forth.

With this you can easily achieve every possible frame border including your example, but you have to re-implement the buttons and the dragging behavior and the response might be a bit less quick than usual. Also the look and feel will then not be OS specific out of the box as it is for Qt's own frame borders.

For example in Linux, the title bar is typically shown differently when maximized - you wouldn't have this then.

Example of custom made frame bar: Customize title bar and window

Community
  • 1
  • 1
NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104