zoukankan      html  css  js  c++  java
  • qt--setWindowFlags各种标志位的窗口样式

    记录一下windowFlags各种标志位的样式和用法,

    代码:

     1 #include "qtwindowflagstest.h"
     2 #include <QtWidgets/QApplication>
     3 #include <QStatusBar>
     4 #include <QObject>
     5 
     6 int main(int argc, char *argv[])
     7 {
     8     QApplication a(argc, argv);
     9     QtWindowFlagsTest w;
    10     w.setGeometry(10, 30, 200, 200);
    11     w.statusBar()->showMessage(QObject::tr("Normal"));
    12     w.show();
    13 
    14     //只有一个关闭按钮
    15     QtWindowFlagsTest w2;
    16     w2.setGeometry(225, 30, 200, 200);
    17     w2.setWindowFlags(Qt::WindowCloseButtonHint);
    18     w2.statusBar()->showMessage("Qt::WindowCloseButtonHint");
    19     w2.show();
    20 
    21     //像对话框一样,有个问号和关闭按钮
    22     QtWindowFlagsTest w3;
    23     w3.setGeometry(440, 30, 200, 200);
    24     w3.setWindowFlags(Qt::WindowContextHelpButtonHint);
    25     w3.statusBar()->showMessage("Qt::WindowContextHelpButtonHint");
    26     w3.show();
    27 
    28     //标题栏也没有 按钮也没有 在那里出现就站在那里不到,也不能移动和拖到,任务栏右击什么也没有,任务栏窗口名也没有,但是可以从任务管理器里关闭
    29     QtWindowFlagsTest w4;
    30     w4.setGeometry(655, 30, 200, 200);
    31     w4.setWindowFlags(Qt::CustomizeWindowHint);
    32     w4.statusBar()->showMessage("Qt::CustomizeWindowHint");
    33     w4.show();
    34 
    35     //窗口只有一个关闭按钮
    36     QtWindowFlagsTest w5;
    37     w5.setGeometry(870, 30, 200, 200);
    38     w5.setWindowFlags(Qt::WindowTitleHint);
    39     w5.statusBar()->showMessage("Qt::WindowTitleHint");
    40     w5.show();
    41 
    42     //只有一个关闭按钮
    43     QtWindowFlagsTest w6;
    44     w6.setGeometry(1085, 30, 200, 200);
    45     w6.setWindowFlags(Qt::WindowSystemMenuHint);
    46     w6.statusBar()->showMessage("Qt::WindowSystemMenuHint");
    47     w6.show();
    48 
    49     //最小化按钮不可用
    50     QtWindowFlagsTest w7;
    51     w7.setGeometry(1300, 30, 200, 200);
    52     w7.setWindowFlags(Qt::WindowMaximizeButtonHint);
    53     w7.statusBar()->showMessage("Qt::WindowMaximizeButtonHint");
    54     w7.show();
    55 
    56     //还原按钮不可用
    57     QtWindowFlagsTest w8;
    58     w8.setGeometry(1515, 30, 200, 200);
    59     w8.setWindowFlags(Qt::WindowMinimizeButtonHint);
    60     w8.statusBar()->showMessage("Qt::WindowMinimizeButtonHint");
    61     w8.show();
    62 
    63     //窗口没有按钮但是有标题栏 任务里什么也看不到
    64     QtWindowFlagsTest w9;
    65     w9.setGeometry(2, 238, 200, 200);
    66     w9.setWindowFlags(Qt::SubWindow);
    67     w9.statusBar()->showMessage("Qt::SubWindow");
    68     w9.show();
    69 
    70     //没有显示在桌面也没在任务。但是任务管里器里还有
    71     QtWindowFlagsTest w10;
    72     w10.setGeometry(217, 238, 200, 200);
    73     w10.setWindowFlags(Qt::Desktop);
    74     w10.statusBar()->showMessage("Qt::Desktop");
    75     w10.show();
    76 
    77     //标题栏也没有 按钮也没有 在那里出现就站在那里不到,也不能移动和拖到,任务栏右击什么也没有,任务栏窗口名也没有, 但是可以从任务管理器里关闭
    78     QtWindowFlagsTest w11;
    79     w11.setGeometry(432, 238, 200, 200);
    80     w11.setWindowFlags(Qt::SplashScreen);
    81     w11.statusBar()->showMessage("Qt::SplashScreen");
    82     w11.show();
    83 
    84     //标题栏也没有 按钮也没有 在那里出现就站在那里不到,也不能移动和拖到,任务栏右击什么也没有,任务栏窗口名也没有, 但是可以从任务管理器里关闭 顶层窗口 一直都是在最上面
    85     QtWindowFlagsTest w12;
    86     w12.setGeometry(647, 238, 200, 200);
    87     w12.setWindowFlags(Qt::ToolTip);
    88     w12.statusBar()->showMessage("Qt::ToolTip");
    89     w12.show();
    90 
    91     //有一个小小的关闭按钮,但是好像不能真正的关闭
    92     QtWindowFlagsTest w13;
    93     w13.setGeometry(862, 238, 200, 200);
    94     w13.setWindowFlags(Qt::Tool);
    95     w13.statusBar()->showMessage("Qt::Tool");
    96     w13.show();
    97 
    98     return a.exec();
    99 }

    结果:

  • 相关阅读:
    springmvc
    POJ 3683 Priest John's Busiest Day
    POJ 3678 Katu Puzzle
    HDU 1815 Building roads
    CDOJ UESTC 1220 The Battle of Guandu
    HDU 3715 Go Deeper
    HDU 3622 Bomb Game
    POJ 3207 Ikki's Story IV
    POJ 3648 Wedding
    HDU 1814 Peaceful Commission
  • 原文地址:https://www.cnblogs.com/Jace-Lee/p/5869496.html
Copyright © 2011-2022 走看看