Important: Please read the Qt Code of Conduct -

[SOLVED]Styling QDockWidget

  • Hi!

    I'm looking for a way how to style floating QDockWidget ( frame more precisely). Bellow is a image how it looks by default ( right image), and one of the possible desired looks (left image, taken from Visual Studio 2012).


    I've looked through examples "here": , but it didn't help.


  • Moderators

    Well there is no (easy) way to style frames in Qt as they are platform specific.
    There are basically two ways, both with their drawbacks and considerable amount of work:

    1. Subclass QDockWidget, and handle the topLevelChanged(bool) signal to make it a frameless window (change widget flags and re-show). Then you would increase margins, draw the frames in paint event and handle all the stuff like resize handles, close button etc in appropriate event handlers.

    2. (Windows specific) Subclass QDockWidget and in winEvent() handle the WM_NCPAINT message by painting with GDI or other machinery.

    I'm no expert on linux so I won't help much there.

    1. way is not an options since is OS dependent.

    I'll try to put first options to practice.


    Marked as solved.


Log in to reply