Дмитрий
July 31, 2017, 12:20 a.m.

Progress bar on the taskbar icon of a Windows application using Qt

The Qt library provides a number of platform-dependent features. One of these features for Windows is the use of the progress bar on the taskbar icon. This option is available for the OS since version 7.

To use this and some other features, you need to connect the winextras module,

  1. QT += winextras

connect library

  1. #include <QtWinExtras>

and add macros

  1. QT_FORWARD_DECLARE_CLASS(QWinTaskbarButton)
  2. QT_FORWARD_DECLARE_CLASS(QWinTaskbarProgress)

In the constructor of the main window we place

  1. if (QtWin::isCompositionEnabled())
  2. QtWin::extendFrameIntoClientArea(this, 0, 0, 0, 0);
  3. else
  4. QtWin::resetExtendedFrame(this);

To display the progress line, you must create a QWinTaskbarButton object,

  1. QWinTaskbarButton *button;
  2. button = new QWinTaskbarButton(this);

bind it to the application window,

  1. button->setWindow(windowHandle());

create a pointer to a QWinTaskbarProgress class object

  1. QWinTaskbarProgress *progress;

and assign it

  1. progress = button->progress();

In many ways, the QWinTaskbarProgress object is identical to the QProgressBar object. For it, you can set the boundaries of the changes different from the default values (0 and 100) using the setMaximum (int), setMinimum (int), setRange (int, int) methods and set the current value using setValue (int). The show () method makes the progress bar visible, hide () has the opposite effect.

The progress bar is displayed in one of 3 colors: green (active mode), yellow (pause), red (stop). After creation, the progress bar is in active mode. You can set or remove the pause mode using the setPaused (bool) function. Calling the stop () method puts the bar in stop mode. From this mode you can not withdraw it. The only possibility is to delete the QWinTaskbarButton object and create a new one. In any of the modes, you can change the values of the progress bar in the direction of increasing or decreasing.

An example of the program can be downloaded from the link .

BlinCT
  • Aug. 5, 2017, 1:45 p.m.

Я так понимаю под линукс такое отсутствует?

Comments

Only authorized users can post comments.
Please, Log in or Sign up
  • Last comments
  • Evgenii Legotckoi
    March 9, 2025, 9:02 p.m.
    К сожалению, я этого подсказать не могу, поскольку у меня нет необходимости в обходе блокировок и т.д. Поэтому я и не задавался решением этой проблемы. Ну выглядит так, что вам действитель…
  • VP
    March 9, 2025, 4:14 p.m.
    Здравствуйте! Я устанавливал Qt6 из исходников а также Qt Creator по отдельности. Все компоненты, связанные с разработкой для Android, установлены. Кроме одного... Когда пытаюсь скомпилиров…
  • ИМ
    Nov. 22, 2024, 9:51 p.m.
    Добрый вечер Евгений! Я сделал себе авторизацию аналогичную вашей, все работает, кроме возврата к предидущей странице. Редеректит всегда на главную, хотя в логах сервера вижу запросы на правильн…
  • Evgenii Legotckoi
    Oct. 31, 2024, 11:37 p.m.
    Добрый день. Да, можно. Либо через такие же плагины, либо с постобработкой через python библиотеку Beautiful Soup
  • A
    Oct. 19, 2024, 5:19 p.m.
    Подскажите как это запустить? Я не шарю в программировании и кодинге. Скачал и установаил Qt, но куча ошибок выдается и не запустить. А очень надо fb3 переконвертировать в html