void Qapplication::alert (Qwidget * widget, int msec = 0)
If the window is not the active window, a warning is displayed to the window. The alert will display msec milliseconds.
If the millisecond is zero, the blink will stop after a period of time, and the taskbar icon will remain lit.
Widget.h
- #ifndef Widget_h
- #define Widget_h
- #include <QWidget>
- #include <QTimer>
- #include <QTime>
- Namespace Ui {
- Class Widget;
- }
- Class Widget:public Qwidget
- {
- Q_object
- Public
- Explicit Widget (Qwidget *parent = 0);
- ~widget ();
- void Setms (int m);
- Public Slots:
- void Start ();
- Private
- Ui::widget *ui;
- int MS;
- Qtimer *timer;
- };
- #endif//Widget_h
Widget.cpp
- #include "Widget.h"
- #include "Ui_widget.h"
- Widget::widget (Qwidget *parent):
- Qwidget (parent),
- UI (New Ui::widget)
- {
- UI->SETUPUI (this);
- Timer = new Qtimer ();
- Timer->setinterval (1000);
- Timer->start ();
- Connect (timer, SIGNAL (), this, SLOT (Start ()));
- }
- Widget::~widget ()
- {
- Delete UI;
- }
- void Widget::start ()
- {
- Qapplication::alert (this, MS);
- }
- void Widget::setms (int m)
- {
- Ms=m;
- }
Main.cpp
- #include "Widget.h"
- #include <QApplication>
- int main (int argc, char *argv[])
- {
- Qapplication A (argc, argv);
- Widget W;
- W.SETMS (1000);
- W.show ();
- return A.exec ();
- }
Http://blog.chinaunix.net/uid-29994589-id-5207150.html
Qapplication::alert If the window is not the active window, a warning is displayed to the window (very useful, as is the case with TeamViewer)