Qt 中去掉标题栏 最大最小 关闭 帮助按钮等总结

有时候标题栏不想让其显示最大最小等按钮,关闭按钮是无法不显示的,可以设置成无法按下失能的状态,但是无法隐藏不可见,只能通过重绘,如果大家有方法实现,请告之我纠正。 

去掉 用&~ 显示用 | 如下:

去掉关闭按钮,去掉帮助按钮:

    setWindowFlags(windowFlags()&~Qt::WindowCloseButtonHint&~Qt::WindowContextHelpButtonHint);

其他想去掉的也可以加到上面代码 比如 加上 Qt::WindowMinMaxButtonsHint  就可以去掉最大最小化按钮 

保留:打开自定义开关,使能窗口标题、最化,最化,关闭。

    setWindowFlags(Qt::CustomizeWindowHint
                   | Qt::WindowTitleHint
                   | Qt::WindowMinimizeButtonHint
                   | Qt::WindowMaximizeButtonHint
                   | Qt::WindowCloseButtonHint
                   );
 
 

    //WindowFlags包括:
    Qt::FrameWindowHint://没有边框的窗口
    Qt::WindowStaysOnTopHint://总在最上面的窗口
    Qt::CustomizeWindowHint://自定义窗口标题栏,以下标志必须与这个标志一起使用才有效,否则窗口将有默认的标题栏
    Qt::WindowTitleHint:显示窗口标题栏
    Qt::WindowSystemMenuHint://显示系统菜单
    Qt::WindowMinimizeButtonHint://显示最小化按钮
    Qt::WindowMaximizeButtonHint://显示最大化按钮
    Qt::WindowMinMaxButtonsHint://显示最小化按钮和最大化按钮
    Qt::WindowCloseButtonHint://显示关闭按钮

猜你喜欢

转载自blog.csdn.net/p942005405/article/details/80492909
今日推荐