QDialog删除标题栏
网络上充斥着类似的问题,但就我所知,没有什么合适的方法可以解决当前的问题.
The net is flooded with similar questions, but for all I have seen nothing suits to solve the problem at hand.
在我的QT-C ++应用程序中,我有一个带有某些功能的主窗口形式,有一个QPushButton,按此键可以打开QDialog.现在,表单中的所有功能都可以正常工作,但是我希望最终的应用程序没有任何顶部标题栏.即没有关闭/最小化/最大化按钮.
In my QT-C++ app, I have a mainwindow form with some functions, there is a QPushButton, Pressing which a QDialog opens. Now, all functionalities in forms work fine, but I want the final application to be without any top title bar. i.e. No Close / Minimize / Maximize Button.
在我的 main.cpp 中,我完成了-
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
w.show();
return a.exec();
}
结果是主窗口变为-
对于 dialog.cpp 窗口,我已设置-
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
//QDialog Dialog(0, Qt::CustomizeWindowHint|Qt::WindowTitleHint); --- used this also; no use
QDialog Dialog(0, Qt::FramelessWindowHint | Qt::Dialog);
但是QDialog的标题栏仍然保留,它看起来像-
But the title bar of QDialog remains, it looks like -
我要去哪里错了???关于如何删除关闭按钮和标题栏的任何想法???
Where am I going wrong ??? any ideas on how to remove the close button and the title bar ???
在朋友的帮助下解决了这个问题,并发布了答案以供有需要的人参考---
Solved it with help from a friend, posting the answer for ready reference for someone in need ---
在mainwindow.cpp中,当按下Fetch按钮时,qdialog打开,我在那里设置了属性;
in the mainwindow.cpp when the Fetch button is pressed, the qdialog opens, I have set the properties there;
void MainWindow::on_pushButton_2_clicked()
{
Dialog dialog;
dialog.setModal(true);
dialog.setWindowFlags(Qt::FramelessWindowHint);
dialog.exec();
}
这成功了-
和对话框-