1
votes

I would like to remove the windows title bar (and minimize/maximize/close buttons) of my QMainWindow. And I would like to use my own minimize/close buttons.

I know how to remove minimize/maximize/close window buttons. It's not a problem. How to remove the window border (containing minimize, maximize and close buttons) from a Qt widget?

The problem is to add those new buttons (minimize/close). Is it possible to do that in Qt Style Sheet (or in C++) ?

ps: I would like something portable for Windows/Mac/Linux

2
Have a look at this answer. I think that this is what you are looking for.Mike

2 Answers

1
votes

You should create window without system bar (without minimize, full-screen, close buttons you can use the next flags for that Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint) and add your own customized system buttons.

1
votes

Unfortunately that kind of decoration depends on the windows manager. You may find OS dependant solutions (this for Windows changes other aspects of the title bar, for example), but if you remove the window buttons, then the only portable option I know is to create your own container window, a QWidget that has a header region with the buttons you want and a centralWiget where you can add the rest of you application:

enter image description here

You then connect header buttons

connect(m_ui.btnMinimize, SIGNAL(clicked()), SLOT(showMinimized()));
connect(m_ui.btnClose, SIGNAL(clicked()), SLOT(close()));

To make it reusable, just add an insert(QWidget*) method to replace the centralWidget.

Note: take into consideration that you must create the container with the Qt::FramelessWindowHint flag set, therefore if you want to allow the user to move/resize the window, you must take care of those actions manually too.