更新代码

master
feiyangqingyun 2022-11-30 09:55:25 +08:00
parent 8a871431e7
commit d2a8f2617a
8 changed files with 23 additions and 23 deletions

View File

@ -30,7 +30,7 @@ FramelessDialog::FramelessDialog(QWidget *parent) : QDialog(parent)
flags = this->windowFlags(); flags = this->windowFlags();
titleBar = 0; titleBar = 0;
//设置背景透明 官方在5.3以后才彻底修复 WA_TranslucentBackground+FramelessWindowHint 并存不绘制的BUG //设置背景透明 官方在5.3以后才彻底修复 WA_TranslucentBackground+FramelessWindowHint 并存不绘制的bug
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0)) #if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
this->setAttribute(Qt::WA_TranslucentBackground); this->setAttribute(Qt::WA_TranslucentBackground);
#endif #endif
@ -50,7 +50,7 @@ FramelessDialog::FramelessDialog(QWidget *parent) : QDialog(parent)
void FramelessDialog::showEvent(QShowEvent *event) void FramelessDialog::showEvent(QShowEvent *event)
{ {
//解决有时候窗体重新显示的时候假死不刷新的BUG //解决有时候窗体重新显示的时候假死不刷新的bug
setAttribute(Qt::WA_Mapped); setAttribute(Qt::WA_Mapped);
QDialog::showEvent(event); QDialog::showEvent(event);
} }
@ -69,7 +69,7 @@ void FramelessDialog::doWindowStateChange(QEvent *event)
//发出最大化最小化等改变事件,以便界面上更改对应的信息比如右上角图标和文字 //发出最大化最小化等改变事件,以便界面上更改对应的信息比如右上角图标和文字
emit windowStateChange(!moveEnable); emit windowStateChange(!moveEnable);
//解决mac系统上无边框最小化失效的BUG //解决mac系统上无边框最小化失效的bug
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
if (windowState() & Qt::WindowMinimized) { if (windowState() & Qt::WindowMinimized) {
isMin = true; isMin = true;

View File

@ -11,9 +11,9 @@
* 6. * 6.
* 7. windows * 7. windows
* 8. windows * 8. windows
* 9. macBUG * 9. macbug
* 10. BUG * 10. bug
* 11. BUG * 11. bug
* 12. 1300 * 12. 1300
* 13. * 13.
* 14. Qt * 14. Qt
@ -41,7 +41,7 @@ protected:
void doResizeEvent(QEvent *event); void doResizeEvent(QEvent *event);
bool eventFilter(QObject *watched, QEvent *event); bool eventFilter(QObject *watched, QEvent *event);
//拦截系统事件用于修复系统休眠后唤醒程序的BUG //拦截系统事件用于修复系统休眠后唤醒程序的bug
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) #if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result); bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result);
#else #else

View File

@ -30,7 +30,7 @@ FramelessMainWindow::FramelessMainWindow(QWidget *parent) : QMainWindow(parent)
flags = this->windowFlags(); flags = this->windowFlags();
titleBar = 0; titleBar = 0;
//设置背景透明 官方在5.3以后才彻底修复 WA_TranslucentBackground+FramelessWindowHint 并存不绘制的BUG //设置背景透明 官方在5.3以后才彻底修复 WA_TranslucentBackground+FramelessWindowHint 并存不绘制的bug
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0)) #if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
this->setAttribute(Qt::WA_TranslucentBackground); this->setAttribute(Qt::WA_TranslucentBackground);
#endif #endif
@ -50,7 +50,7 @@ FramelessMainWindow::FramelessMainWindow(QWidget *parent) : QMainWindow(parent)
void FramelessMainWindow::showEvent(QShowEvent *event) void FramelessMainWindow::showEvent(QShowEvent *event)
{ {
//解决有时候窗体重新显示的时候假死不刷新的BUG //解决有时候窗体重新显示的时候假死不刷新的bug
setAttribute(Qt::WA_Mapped); setAttribute(Qt::WA_Mapped);
QMainWindow::showEvent(event); QMainWindow::showEvent(event);
} }
@ -69,7 +69,7 @@ void FramelessMainWindow::doWindowStateChange(QEvent *event)
//发出最大化最小化等改变事件,以便界面上更改对应的信息比如右上角图标和文字 //发出最大化最小化等改变事件,以便界面上更改对应的信息比如右上角图标和文字
emit windowStateChange(!moveEnable); emit windowStateChange(!moveEnable);
//解决mac系统上无边框最小化失效的BUG //解决mac系统上无边框最小化失效的bug
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
if (windowState() & Qt::WindowMinimized) { if (windowState() & Qt::WindowMinimized) {
isMin = true; isMin = true;

View File

@ -11,9 +11,9 @@
* 6. * 6.
* 7. windows * 7. windows
* 8. windows * 8. windows
* 9. macBUG * 9. macbug
* 10. BUG * 10. bug
* 11. BUG * 11. bug
* 12. 1300 * 12. 1300
* 13. * 13.
* 14. Qt * 14. Qt
@ -41,7 +41,7 @@ protected:
void doResizeEvent(QEvent *event); void doResizeEvent(QEvent *event);
bool eventFilter(QObject *watched, QEvent *event); bool eventFilter(QObject *watched, QEvent *event);
//拦截系统事件用于修复系统休眠后唤醒程序的BUG //拦截系统事件用于修复系统休眠后唤醒程序的bug
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) #if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result); bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result);
#else #else

View File

@ -30,7 +30,7 @@ FramelessWidget::FramelessWidget(QWidget *parent) : QWidget(parent)
flags = this->windowFlags(); flags = this->windowFlags();
titleBar = 0; titleBar = 0;
//设置背景透明 官方在5.3以后才彻底修复 WA_TranslucentBackground+FramelessWindowHint 并存不绘制的BUG //设置背景透明 官方在5.3以后才彻底修复 WA_TranslucentBackground+FramelessWindowHint 并存不绘制的bug
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0)) #if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
this->setAttribute(Qt::WA_TranslucentBackground); this->setAttribute(Qt::WA_TranslucentBackground);
#endif #endif
@ -50,7 +50,7 @@ FramelessWidget::FramelessWidget(QWidget *parent) : QWidget(parent)
void FramelessWidget::showEvent(QShowEvent *event) void FramelessWidget::showEvent(QShowEvent *event)
{ {
//解决有时候窗体重新显示的时候假死不刷新的BUG //解决有时候窗体重新显示的时候假死不刷新的bug
setAttribute(Qt::WA_Mapped); setAttribute(Qt::WA_Mapped);
QWidget::showEvent(event); QWidget::showEvent(event);
} }
@ -69,7 +69,7 @@ void FramelessWidget::doWindowStateChange(QEvent *event)
//发出最大化最小化等改变事件,以便界面上更改对应的信息比如右上角图标和文字 //发出最大化最小化等改变事件,以便界面上更改对应的信息比如右上角图标和文字
emit windowStateChange(!moveEnable); emit windowStateChange(!moveEnable);
//解决mac系统上无边框最小化失效的BUG //解决mac系统上无边框最小化失效的bug
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
if (windowState() & Qt::WindowMinimized) { if (windowState() & Qt::WindowMinimized) {
isMin = true; isMin = true;

View File

@ -11,9 +11,9 @@
* 6. * 6.
* 7. windows * 7. windows
* 8. windows * 8. windows
* 9. macBUG * 9. macbug
* 10. BUG * 10. bug
* 11. BUG * 11. bug
* 12. 1300 * 12. 1300
* 13. * 13.
* 14. Qt * 14. Qt
@ -41,7 +41,7 @@ protected:
void doResizeEvent(QEvent *event); void doResizeEvent(QEvent *event);
bool eventFilter(QObject *watched, QEvent *event); bool eventFilter(QObject *watched, QEvent *event);
//拦截系统事件用于修复系统休眠后唤醒程序的BUG //拦截系统事件用于修复系统休眠后唤醒程序的bug
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) #if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result); bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result);
#else #else

View File

@ -28,7 +28,7 @@ bool FramelessWidget2::eventFilter(QObject *watched, QEvent *event)
{ {
if (widget != 0 && watched == widget) { if (widget != 0 && watched == widget) {
if (event->type() == QEvent::WindowStateChange) { if (event->type() == QEvent::WindowStateChange) {
//解决mac系统上无边框最小化失效的BUG //解决mac系统上无边框最小化失效的bug
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
if (widget->windowState() & Qt::WindowMinimized) { if (widget->windowState() & Qt::WindowMinimized) {
isMin = true; isMin = true;

View File

@ -56,7 +56,7 @@ public Q_SLOTS:
//设置是否可拖动+拉伸 //设置是否可拖动+拉伸
void setMoveEnable(bool moveEnable); void setMoveEnable(bool moveEnable);
void setResizeEnable(bool resizeEnable); void setResizeEnable(bool resizeEnable);
//修复部分控件不能自动识别 MouseButtonRelease 的BUG //修复部分控件不能自动识别 MouseButtonRelease 的bug
void setMousePressed(bool mousePressed); void setMousePressed(bool mousePressed);
//设置要无边框的窗体 //设置要无边框的窗体