QDialog删除标题栏 [英] QDialog remove title bar

查看:94
本文介绍了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();
}

这成功了-

和对话框-

这篇关于QDialog删除标题栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆