问题
I show a dialog in my qt application on menu action click window is appearing perfectly but I want to hide its title bar as it is just a sub-window inside main window.
I tried :
this->setWindowFlags(Qt::Window |Qt::FramelessWindowHint);
In dialog constructor:
ui->setupUi(this);
this->setWindowState (Qt::WindowActive);
setWindowModality(Qt::ApplicationModal);
setAttribute (Qt::WA_DeleteOnClose);
this->setWindowFlags(Qt::Window |Qt::FramelessWindowHint) ; //
This does remove the title bar but it also hides the main window, which is bad for my application.
How can I hide dialog title bar without disturbing the base main window of the application?
回答1:
QDialog *dialog(new QDialog /* this should be your dialog class youve created obviously*/));
dialog->setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
dialog->show();
回答2:
You're missing the CustomizeWindowHint.
As you can see from the source code here (line 1035) for QWidget, it decides what to do depending upon that flag. So I suggest trying this: -
setWindowFlags(Qt::Window | Qt::CustomizeWindowHint);
来源:https://stackoverflow.com/questions/26015880/how-to-hide-titlebar-of-the-qdialog-window