Important: Please read the Qt Code of Conduct -

Custom QDialog titlebar and border

  • Hello

    I have an app that I’d like to have a custom look. I have used the frameless window hint and created my own window manager to manage moving and resizing the window, but it does not support Windows Aero features like Aero Snap and Aero Shake.

    Two questions:

    1. Is it possible to add Aero support to a QDialog while keeping the frameless window hint?
    2. If I remove the frameless window hint it shows a Windows-themed border and titlebar around the window, which on Windows 7 is pretty ugly (it looks like Notepad). Is there a way to customize the titlebar and border? None of the standard Win32 calls I’ve seen on the web to do this seem to work with a Qt window.


  • Moderators

    @ANT1CS said in Custom QDialog titlebar and border:

    None of the standard Win32 calls I’ve seen on the web to do this seem to work with a Qt window.

    yes, of course they do not support a Qt window directly. But a QWindow lets you get a native window handle which you can then pass to the WinAPI.

    Also you might want to see this (untested, but worth a try)

  • I've gone that route already. None of the Win32 calls work using the HWND I get from my Qt window. Qt doesn't seem to support drawing using the WM_NCPAINT event for instance.

  • Lifetime Qt Champion

    WM_NCPAINT can be handled with

    However, the custom decorations (windows borders/caption) is huge amount of work and if you really want it, i
    suggest reusing some of the attempts been made already.

  • @ANT1CS Have you tried this:

    I've been looking for the Aero snap/shake feature for a while now and this seems to be a good solution for me.

    There is a "tweak" required in order to compile for QT 5.9.1 (which I'm presently running) whereby in the QWinHost.cpp file, you need to change the following line (257):

    hwnd = createWindow((HWND)winId(), qWinAppInst());

    change to

    hwnd = createWindow((HWND)winId(), (HINSTANCE)QWidget::effectiveWinId());

Log in to reply