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)

Source: Internet
Author: User

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

  1. #ifndef Widget_h
  2. #define Widget_h
  3. #include <QWidget>
  4. #include <QTimer>
  5. #include <QTime>
  6. Namespace Ui {
  7. Class Widget;
  8. }
  9. Class Widget:public Qwidget
  10. {
  11. Q_object
  12. Public
  13. Explicit Widget (Qwidget *parent = 0);
  14. ~widget ();
  15. void Setms (int m);
  16. Public Slots:
  17. void Start ();
  18. Private
  19. Ui::widget *ui;
  20. int MS;
  21. Qtimer *timer;
  22. };
  23. #endif//Widget_h

Widget.cpp

  1. #include "Widget.h"
  2. #include "Ui_widget.h"
  3. Widget::widget (Qwidget *parent):
  4. Qwidget (parent),
  5. UI (New Ui::widget)
  6. {
  7. UI->SETUPUI (this);
  8. Timer = new Qtimer ();
  9. Timer->setinterval (1000);
  10. Timer->start ();
  11. Connect (timer, SIGNAL (), this, SLOT (Start ()));
  12. }
  13. Widget::~widget ()
  14. {
  15. Delete UI;
  16. }
  17. void Widget::start ()
  18. {
  19. Qapplication::alert (this, MS);
  20. }
  21. void Widget::setms (int m)
  22. {
  23. Ms=m;
  24. }

Main.cpp

      1. #include "Widget.h"
      2. #include <QApplication>
      3. int main (int argc, char *argv[])
      4. {
      5. Qapplication A (argc, argv);
      6. Widget W;
      7. W.SETMS (1000);
      8. W.show ();
      9. return A.exec ();
      10. }

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.