Search code examples
qtdialoghidetitlebar

How to hide titlebar of the QDialog window?


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?


Solution

  •  QDialog *dialog(new QDialog /* this should be your dialog class youve created obviously*/));
     dialog->setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
     dialog->show();