PDA

View Full Version : How to remove title but with frame border?



shaoli.xie
9th April 2012, 16:29
hello, friends..
i wanna to put my widget on the title bar with qt

on window platform,
i use Qt::FrameLessWindowHint to hide the caption, and use WM_NCHITTEST to deal with move and resize.
but without borders, i move the window to screen edge, window can't maximum or restore by system.......

then , i tried to use SetWindowLong() to make border back...it works, but too ugly....code and the widget..
at last, i make client area over title bar with WM_NCCALCSIZE message, it works, but have many bugs....then, i changes lots of QtGui's codes to make it deal with WM_NCCALCSIZE... update frameStruct and client Rect etc..

but, on linux platform, i can't find any help from XLib Api... can i create canvas intead of window?
or use Qt::FrameLessWindowHint, and try to solver Scrren Edge problem?

thanks for any reply...

so poor my english....

Spitfire
10th April 2012, 11:01
Hmm I don't quite understand what you mean by 'put my widget on the title bar with qt'.

Do you want to get rid of the title bar of a widget (top part of a widget with title, max/min/close buttons)?
Or do you want to get rid of entry on the window task bar (on the bottom of the screen when icon of your app appears)?

Whatever you want, I can bet that there's no need to go native, this way you make your code not-portable.
Qt should suffice.

And what 'screen edge problem' you mean?

Berryblue031
10th April 2012, 12:12
If you have a frameless window and want to be able to maximize / minimize / close it by the system you need to add some more window flags


FramelessWindow::FramelessWindow()
: QWidget(0, Qt::WindowFlags(Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint | Qt::WindowSystemMenuHint))

If you want to be able to grab the edges of your window and resize it you will have to implement this yourself or use a utility like Frameless Window Helper (http://qt-apps.org/content/show.php?content=138161)

shaoli.xie
11th April 2012, 10:03
er..like this..7576
like opera, firefox or chrome 's title bar.
1. it was able to resize and move....
2. i move my window to the top of Screen, then release mouse, my window will be maximized......(with borders, my window can recieve WM_SIZE messages from system.)
like this, 7577
everything is perfect on Window Platform...after change some QtGui 's code...

but i don't know how to do the same thing in linux.
i know how to use Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint | Qt::WindowSystemMenuHint...but without border, i can't drag my window to the edge of screen, and do something..

thanks.

Added after 10 minutes:

i can't find any method to remove window title bar, but keep the window border in Qt.
so i have to use Native Api ... so i have to do the same thing in different platform....is ok, i don't care..

Spitfire
11th April 2012, 14:14
Your attachements are not working.


but without border, i can't drag my window to the edge of screen, and do something..
With border you can't either. You want to remove title bar but AFAIK that's only way to drag the window around. Borders change only window size.

If you want to change that behaviour, take a simple frameless window, make border out of it to implement dragging and stick all the content you want insde.
Simple and cross-platform solution.