QWidget:: close button hint
-
wrote on 7 Dec 2011, 17:27 last edited by
"This":http://doc.qt.nokia.com/4.7/widgets-windowflags.html example teaches you to use the window flags.
-
wrote on 7 Dec 2011, 17:37 last edited by
setWindowFlags sets all flags at once. You must do a bitwise or of all flags:
@
setWindowFlags(Qt::CustomizeWindowHint) | Qt::WindowCloseButtonHint);
@Be aware that with that line, you reset every other flag!
-
wrote on 8 Dec 2011, 10:09 last edited by
I tried @setWindowFlags(Qt::CustomizeWindowHint) | Qt::WindowCloseButtonHint);@ But it is not working in my case.
In my mainwidget, I am adding Widget1 and Widget2 in a QVBoxLayout. Can a widget2 in a QVBoxLayout have a Close button hint as I needed.
I need to have a closebutton for my Widget2, after adding it to a VBoxLayout. I am working on openSuSe 12.1 OS.
Thanks..
-
wrote on 8 Dec 2011, 10:50 last edited by
The close buttons (and the other elements settable by window flags) are for toplevel windows only. Most if not all of them do not have any influence on child widgets.
So, the short story: no, you can't have a close button on a subwidget by setting a window flag.
-
wrote on 8 Dec 2011, 11:34 last edited by
Ok thanks for the info..
I wrote a keypressevent for widget2 and catching Key_Escape and then hiding the widget.. Just a workaround..
<CLOSED>
Thanks..
-
wrote on 8 Dec 2011, 13:11 last edited by
[quote author="haney" date="1323344057"]Ok thanks for the info..
<CLOSED>
[/quote]
Closing of topics is only done when needed, and then by moderators or admins. So, topic is not closed. I am, however, glad it is [Solved] for you :-) -
wrote on 16 May 2012, 11:21 last edited by
Hi all,
I need to have at least a small icon/button/action in my widget to have CLOSE button functionality. There should be some obvious symbol/icon for the user to understand that there is CLOSE option for my widget.
Appreciate your help in this regard.
Thanks,
Haney. -
wrote on 16 May 2012, 11:26 last edited by
[quote author="haney" date="1337167277"]Hi all,
I need to have at least a small icon/button/action in my widget to have CLOSE button functionality. There should be some obvious symbol/icon for the user to understand that there is CLOSE option for my widget.
Appreciate your help in this regard.
Thanks,
Haney.[/quote]As you could have read in this topic already: there is no* support for providing close buttons/hints/options/whatevers for non-top-level widgets in Qt. If you want to provide that functionality, you will have to provide it.
*) Ok, perhaps there is some, like the close buttons on tabs, but not for the general case.
-
wrote on 8 Jun 2020, 08:34 last edited by
Hi Haney,
You can use "close()" function simply by putting a push button and writing clicked slot for this button
-
Hi Haney,
You can use "close()" function simply by putting a push button and writing clicked slot for this button