How to set my layout to title bar in windows?
-
Please check this link to download the image file.
Any help would be appreciated
Thanks. -
Link is not working!
-
yes i have updated the link.
-
This is a custom title bar and the title bar is part of the OS and not directly manageable by Qt.
You can customize the title bar in two ways:1.) use the OS way (overwrite e.g. winEvent and implement messages like WM_NCXXX)
2.) remove the OS titlebar and create a widget instead.Using the second way, you can use Qt but you loose the OS integration on windows (like task bar button, window move, etc.)
-
Okay Gerolf thanks
But how can i achieve this by coding.
if I use 1st way then,should I paint the title bar or any else.
and if I use 2nd then can I mange the min,max close button on custom title bar and how to hide the orignal one.
Please guide with some example.Thanks.
-
Hi Jack,
if you use the OS specific part, google a bit for windows custom titlebar, that should give you results (way 1).
If you remove the standard header, use widget attributes (see QWidget docu and examples). The buttons must then be done by you on your own. -
I have done this a couple times. Set your Main Window Widget background to translucent. Use an QVBoxLayout to separate a title from the main window. Make a title bar widget subclass.
For click and drag movement of the application, pick up the mouse click / move event, then send a signal to the main window telling where to move too (for the same functionality as the windows OS title bar).
For Resizing, you can add a QSizeGrip on the bottom right in a custom widget as well and set its parent to the main window. It should do its job.
When I did it, I had a title bar, the main section of the app, and a bottom bar. The title bar contained a QHBoxLayout with a label and a few buttons for minimize, help, and close, and a bottom bar contained a label and the size grip.
-
The downside of custom window borders rendering is that you have to be very careful to preserve the native OS feel. For some examples:
doubleclick on the title bar should maximize/demaximize the window but this is way to often handled wrong on multi-monitor configs ie. app always maximizes on the primary screen instead of the screen it was sitting.
Windows Vista/7 introduced some new windowing features like
window snap - windows snap to the side edges of screen, maximize when dragged to top edge and demaximize by dragging, new shortcuts like Win+arrows etc, this also works for resizing by grabbing edges.
window peek - new ways to "preview" app window eg. by hovering over taskbar thumbnail
window shake - closing all other opened windows by grabbing and shaking title barThere are probably similar OS functions on linux and macos. By disabling native window frame you are obligated to provide those facilities yourself or your app will feel out of place no matter how pretty your window is.
-
Hi dvez43,
I'm new to Qt - how can this be done? -
Hi jack,
please use the search on the forum, those things hjave been discussed here already.
Additionally to what Krzysztof said, on Windows also things like task bar in tegration, task bar menu etc. do not work. Custom window title windows also sometimes (don't kwnow whether it's windows version dependant) maximize to full screen (and therefore hide a fixed windows task bar) instead of maximizied windows. -
ohh sorry...!
I'm new to this forum.
But I'll take care about this for next time.