基于Qt开发类似QQ消息闪动效果

   1.首先谈到QSystemTrayIcon设置系统托盘等功能,具体参考Qt帮助文档。

   2.类似QQ闪动效果,其实是图片的交替显示产生的视觉效果。

   3.使用定时器或者类似交替循环等功能交替显示图片,其中一张图片可以切成透明色的,这样效果就产生啦。

   4.贴段代码看看

WebView::WebView(QWidget *parent) :
    QWebView(parent)
{
    setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);
    Cmstring::initCmString();
    msg = new MsgWidget(0);
    connect(this,SIGNAL(loadFinished(bool)),msg,SLOT(slotLoadFinished(bool)));

    timerShow = new QTimer(this);
    connect(timerShow,SIGNAL(timeout()),this,SLOT(slotTimeShowOut()));

    timerHide = new QTimer(this);
    connect(timerHide,SIGNAL(timeout()),this,SLOT(slotTimeHideOut()));

    load(ndooUrl);
    setTrayIcon();
    slotLoadFinished(false);
}
void WebView::slotLoadFinished(bool)
{
    timerShow->start(500);
}

void WebView::slotTimeShowOut()
{
    qDebug()<<"NdooWebView::slotTimeShowOut ";
    trayIcon->setIcon(QIcon(":/img/logo.png"));
    trayIcon->show();
    timerHide->start(500);
}

void WebView::slotTimeHideOut()
{
    qDebug()<<"NdooWebView::slotTimeHideOut ";
    trayIcon->setIcon(QIcon(":/img/logo_1.png"));
    timerShow->start(500);
}



你可能感兴趣的:(QT)