Hiding QMdiArea's title bar

3.3k views Asked by At

MainWindow can easily hide the title bar use :

setWindowFlags(Qt::CustomizeWindowHint);

But when doing with QMdiArea, like:

ui->mdiArea->setWindowFlags(Qt::CustomizeWindowHint);
ui->mdiArea->addSubWindow(child);
child->showMaximized();

Things could not work. I also try this:

child->setWindowFlags(Qt::CustomizeWindowHint);

and this:

setWindowFlags(Qt::WindowTitleHint);

It still showesenter image description here

So How can I do?

BTW: if can't make this, can I disable the 3 buttons on the left or overload these buttons event.

2

There are 2 answers

3
Klathzazt On

This works for me:

child->setWindowFlags(Qt::FramelessWindowHint);

Here is an example creating a sub window that is a QLineEdit. The sub window does not have a title bar:

void MainWindow::on_pushButtonAddSubWindow_clicked(){
  QLineEdit *edit = new QLineEdit(QString("Test"), this);
  QMdiSubWindow *sub = ui->mdiArea->addSubWindow(edit);
  sub->setWindowFlags(Qt::FramelessWindowHint);
  edit->show();
}
0
Straticiuc Vicu On

@Klathzazt solution worked for me as he described. Also you can use

auto w = new QWidget();
auto sub_w = area_.addSubWindow(w, 
             Qt::CustomizeWindowHint | Qt::Tool | Qt::WindowTitleHint);
sub_w->show();`<br>to create windows that have only title bar(no buttons).