记录一下windowFlags各种标志位的样式和用法,
Qt之自定义界面(窗体缩放)
// 设置无边框
setWindowFlags(Qt::FramelessWindowHint);
// 背景透明
setAttribute(Qt::WA_TranslucentBackground, true);
setWindowOpacity(0.5); //设置背景透明度 0为完全透明
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); //设置窗口置顶
代码:
#include "qtwindowflagstest.h"
#include <QtWidgets/QApplication>
#include <QStatusBar>
#include <QObject>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QtWindowFlagsTest w;
w.setGeometry(10, 30, 200, 200);
w.statusBar()->showMessage(QObject::tr("Normal"));
w.show();
//只有一个关闭按钮
QtWindowFlagsTest w2;
w2.setGeometry(225, 30, 200, 200);
w2.setWindowFlags(Qt::WindowCloseButtonHint);<
Qt之自定义界面(窗体缩放)
// 设置无边框
setWindowFlags(Qt::FramelessWindowHint);
// 背景透明
setAttribute(Qt::WA_TranslucentBackground, true);
setWindowOpacity(0.5); //设置背景透明度 0为完全透明
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); //设置窗口置顶
代码:
#include "qtwindowflagstest.h"
#include <QtWidgets/QApplication>
#include <QStatusBar>
#include <QObject>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QtWindowFlagsTest w;
w.setGeometry(10, 30, 200, 200);
w.statusBar()->showMessage(QObject::tr("Normal"));
w.show();
//只有一个关闭按钮
QtWindowFlagsTest w2;
w2.setGeometry(225, 30, 200, 200);
w2.setWindowFlags(Qt::WindowCloseButtonHint);<