Unsolved really stupid question about Frameless
-
Hello,
Today I have a very stupid question... I want to redisplay the frame of a frameless window
my Widget is a QPushButton (for test purpose)
widget.setWindowFlags(QtCore.Qt.Widget | QtCore.Qt.FramelessWindowHint)now, i want to RE display the frame
I ve tried this but it didn't do anything except closing the window...
widget.setWindowFlags(widget.windowFlags() ^ QtCore.Qt.FramelessWindowHint)What is wrong with this ?
Thx !
-
Just remove the setwindowFlags. You can get the frame back
-
What do you mean ?
directly : widget.windowFlags() ^ QtCore.Qt.FramelessWindowHint ?? (it doesn't work)
-
Oh No, not like that.
I asked to remove the complete line
setWindowFlags(QtCore.Qt.Widget | QtCore.Qt.FramelessWindowHint).
//This line of code,. gives you frameless window. So remove it and you will have window with frame.Lets take an example:
QDialog * dialog = new QDialog;
dialog->setWindowFlags(setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog););
// If you have this setwidnowFlag with FramlessWindowHint mean asking for //frames less Dialog.If you don't have this line mean , that you will have dialog with //default frame and hint icon ,m basing on your OS.ObjectName->setWindowsFlags(....) or directly in constructor setWindowsFlags(....) is used to specify the window-system properties of the widget. When you don't want change / specify window properties, then you don't need to set any windowFlags.
-
the thing is I am using the frameless when the mouse is moving and then when i release the mouse button I want to re display the frame. So I can't simply remove the line from my code ...
-
Do I understand correctly ?
So when you click mouse on the Dialog, it has to be framless and after the release of the mosue, again the dialog has to be with frame?
Or
Are you looking for any dragging frameless Dialog/widget ? -
Yes, that's it
The idea it to create a custom drag to take a widget out of the main window. So by setting its parent to None it automatically creates a frame around it that I am removing so i looks like the QDrag and then when i "drop" I want to re display the frame so it looks like a window. -
Well both you can do using the mouseEvents. See this sample code
https://forum.qt.io/topic/34354/solved-frameless-window-dragging-issue/3 -
The thing is I don t want to do that, for consistency purpose I want the window frame so it matches any other window style.
A solution would be on mouseReleaseEvent to create a new QWindow and parent the widget inside ...
-
After you've changed window flags on a visible window you need to call
show()
again for the new setting to take effect. That's just how window managers work. It's documented here.