Qt每3秒后你QQ一样任务栏闪烁
https://download.csdn.net/download/zhujianqiangqq/19822160 代码包下载
.pro
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 QT += core gui 2 3 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 5 CONFIG += c++11 6 7 # The following define makes your compiler emit warnings if you use 8 # any Qt feature that has been marked deprecated (the exact warnings 9 # depend on your compiler). Please consult the documentation of the 10 # deprecated API in order to know how to port your code away from it. 11 DEFINES += QT_DEPRECATED_WARNINGS 12 13 # You can also make your code fail to compile if it uses deprecated APIs. 14 # In order to do so, uncomment the following line. 15 # You can also select to disable deprecated APIs only up to a certain version of Qt. 16 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 17 18 SOURCES += \ 19 main.cpp \ 20 mainwindow.cpp 21 22 HEADERS += \ 23 mainwindow.h 24 25 FORMS += \ 26 mainwindow.ui 27 28 # Default rules for deployment. 29 qnx: target.path = /tmp/$${TARGET}/bin 30 else: unix:!android: target.path = /opt/$${TARGET}/bin 31 !isEmpty(target.path): INSTALLS += target
main.cpp
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include "mainwindow.h" 2 3 #include <QApplication> 4 5 int main(int argc, char *argv[]) 6 { 7 QApplication a(argc, argv); 8 MainWindow w; 9 w.show(); 10 return a.exec(); 11 }
mainwindow.h
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #ifndef MAINWINDOW_H 2 #define MAINWINDOW_H 3 4 #include <QMainWindow> 5 #include <QTimer> 6 7 QT_BEGIN_NAMESPACE 8 namespace Ui { class MainWindow; } 9 QT_END_NAMESPACE 10 11 class MainWindow : public QMainWindow 12 { 13 Q_OBJECT 14 15 public: 16 MainWindow(QWidget *parent = nullptr); 17 ~MainWindow(); 18 19 private: 20 void on_TimerEvent(); 21 22 private: 23 Ui::MainWindow *ui; 24 QTimer *m_pTimer = NULL; 25 }; 26 #endif // MAINWINDOW_H
mainwindow.cpp
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include "mainwindow.h" 2 #include "ui_mainwindow.h" 3 4 #ifdef Q_OS_WIN 5 #pragma comment(lib, "user32.lib") 6 #include <qt_windows.h> 7 #endif 8 9 MainWindow::MainWindow(QWidget *parent) 10 : QMainWindow(parent) 11 , ui(new Ui::MainWindow) 12 { 13 ui->setupUi(this); 14 15 m_pTimer = new QTimer(this); 16 m_pTimer->setSingleShot(false); 17 m_pTimer->start(3000);// 每3秒后你QQ一样任务栏闪烁 18 connect(m_pTimer, &QTimer::timeout, this, &MainWindow::on_TimerEvent); 19 } 20 21 MainWindow::~MainWindow() 22 { 23 delete ui; 24 } 25 26 void MainWindow::on_TimerEvent() 27 { 28 FlashWindow(HWND(this->winId()), true); 29 }
作者:疯狂Delphi
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
欢迎关注我,一起进步!扫描下方二维码即可加我
![](https://images.cnblogs.com/cnblogs_com/FKdelphi/1101510/o_200417075318%E5%8A%A0%E6%88%91QQ.jpg)
![](https://images.cnblogs.com/cnblogs_com/FKdelphi/1101510/o_200417080925%E5%8A%A0%E6%88%91%E5%BE%AE%E4%BF%A1.jpg)