Reputation: 2037
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 showes
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.
Upvotes: 1
Views: 3440
Reputation: 122
@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).
Upvotes: 1
Reputation: 2454
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();
}
Upvotes: 2