日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > c/c++ >内容正文

c/c++

QT 提示之右下角冒泡

發(fā)布時(shí)間:2025/3/15 c/c++ 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 QT 提示之右下角冒泡 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

實(shí)現(xiàn)原理

  • ?顯示
    ? 定時(shí)器啟動(dòng),右下角緩慢彈出,逐漸改變位置
  • 駐留
    ? 讓界面停留一定的時(shí)間,時(shí)間過(guò)后自動(dòng)關(guān)閉。
  • 退出
    可以直接點(diǎn)擊關(guān)閉退出,也可以采用改變透明度的形式模糊退出。
  • #ifndef _QTOOLTIPS_ #define _QTOOLTIPS_ #include <QTimer> #include <QDialog> #include "ui_QToolTips.h"class QToolTips:public QDialog {Q_OBJECTpublic:QToolTips(QWidget *parent = 0);~QToolTips();void showMessage(const char* str);private slots:void onMove();void onStay();-void onClose();private:Ui::QToolTips ui;QTimer * m_pShowTimer;QTimer * m_pStayTimer;QTimer * m_pCloseTimer;QPoint m_point;int m_nDesktopHeight;double m_dTransparent;};#endif
    #include "QToolTips.h" #include <QtWidgets/QApplication> #include <QDesktopWidget>QToolTips::QToolTips(QWidget *parent /*= 0*/): QDialog(parent) {setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);ui.setupUi(this);m_nDesktopHeight = QApplication::desktop()->height();m_dTransparent = 1.0;m_pShowTimer = new QTimer(this);m_pStayTimer = new QTimer(this);m_pCloseTimer = new QTimer(this);connect(m_pShowTimer, SIGNAL(timeout()), this, SLOT(onMove()));connect(m_pStayTimer, SIGNAL(timeout()), this, SLOT(onStay()));connect(m_pCloseTimer, SIGNAL(timeout()), this, SLOT(onClose()));}QToolTips::~QToolTips() {}void QToolTips::showMessage(const char* str) {ui.m_label->setStyleSheet("background-color:rgb(255,210,200);font:60px;color:blue");ui.m_label->setText(str);QRect rect = QApplication::desktop()->availableGeometry();m_point.setX(rect.width() - width());m_point.setY(rect.height() - height());move(m_point.x(), m_point.y());m_pShowTimer->start(5);}void QToolTips::onMove() {m_nDesktopHeight--;move(m_point.x(), m_nDesktopHeight);if (m_nDesktopHeight <= m_point.y()){m_pShowTimer->stop();m_pStayTimer->start(5000);}}void QToolTips::onStay() {m_pStayTimer->stop();m_pCloseTimer->start(100);}void QToolTips::onClose() {m_dTransparent -= 0.1;if (m_dTransparent <= 0.0){m_pCloseTimer->stop();close();}else{setWindowOpacity(m_dTransparent);}}

    總結(jié)

    以上是生活随笔為你收集整理的QT 提示之右下角冒泡的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

    如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。