Reputation: 35
I noticed that some applications based on Qt have a button with a context menu in their title bar, I would like to achieve a similar effect in my application, can someone tell me how to achieve it? The image shows one of those applications with the button clicked showing the context menu Button with Context Menu
Thanks in advance...
Upvotes: 2
Views: 3045
Reputation: 8311
The title bar is generally handled by the window manager (DWM on Windows or KWin for KDE on Linux, etc.).
There are only a limited things you can do to customize the native title bar, and it will not be portable.
What you can do is disable the native title bar by using Qt::WindowTitleHint
or Qt::FramelessWindowHint
and implements your own title bar within your software. But this has some drawbacks as you lose some of the features provided by the window manager.
You can start by looking at these forum posts:
Upvotes: 3
Reputation: 1
One of the option: if You use QML you can create your custom window title bar by setting Qt.FramelessWindowHint. Then inside create your own titlebar Rectangle with everything that you want
Window {
visible: true
width: 640
height: 480
flags: Qt.FramelessWindowHint
}
But unfortunately you will need to write all windows controls (moving, sizing, buttons ...) from scratch (here is some info about moving)
Upvotes: 0