0
votes

I'm working on an Qt app. I should create a pop-up window that has only a close button with no toolbar, minimize and maximize buttons.

Any idea how to do this?

Snippet Close button with no toolbar

3

3 Answers

0
votes

I don't know by "no toolbar" you mean "no title bar" or not, but this example can help you. Anyway, by using the following code you can have a window with just close button, and "title bar":

window->setWindowFlags(Qt::Window | Qt::WindowCloseButtonHint);

If you don't want the title bar too, try to remove it and design it by yourself.

0
votes

you could change the window-flags. But your expected window calls for a QDialog: has no menu-bar and just a close-button (out of the box). Else refer to this ( https://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.html ) and set the flag for Qt::WindowCloseButtonHint.

0
votes

If you use setWindowFlags(Qt::Window | Qt::FramelessWindowHint); you will get rid of the title bar, but with it all buttons that live on the titlebar, including the close button.

This will mean you will need to implement a way to move the window, as the title bar is used for this purpose. See this answer

Then implement your own titlebar class with a close button that you can put at the top of your dialog.

Unfortunately you don't have any control over the system titlebar appearance, so it's not possible to stylesheet your way out of this problem.