2014-09-24 84 views
0

我在菜单动作中的qt应用程序中显示一个对话框单击窗口显示完美,但我想隐藏它的标题栏,因为它只是主窗口内的子窗口。 我试图如何在Qt中隐藏对话框的标题栏

this->setWindowFlags(Qt::Window |Qt::FramelessWindowHint) ; 

在对话框的构造

ui->setupUi(this); 
this->setWindowState (Qt::WindowActive); 
setWindowModality(Qt::ApplicationModal); 
setAttribute (Qt::WA_DeleteOnClose); 
this->setWindowFlags(Qt::Window |Qt::FramelessWindowHint) ; // 

这确实删除标题栏,但它也隐藏了主窗口,这是坏我的应用程序。 请帮助我如何隐藏对话框标题栏而不会干扰应用程序的基本主窗口。

回答

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

AngryDuck thanx !! ,这对我的应用程序 – Deepti 2014-09-25 10:19:03

+0

没有问题....... :) – AngryDuck 2014-09-25 12:38:10

1

您错过了CustomizeWindowHint。

正如您从source code here(第1035行)中可以看到的QWidget,它根据该标志决定该做什么。所以我建议试试这个: -

setWindowFlags(Qt::Window | Qt::CustomizeWindowHint); 
+0

你的建议工作方式与此 - > setWindowFlags(Qt :: Window | Qt :: FramelessWindowHint),它隐藏标题栏的窗口,但也使应用程序的主窗口错位。 – Deepti 2014-09-25 10:16:18

+0

thanx你的答案很好,但它不适合我的应用程序,因为我想隐藏“对话框”的标题栏而不是窗口。您的答案可以在mainwindow小部件中正常工作 – Deepti 2014-09-25 10:32:05