Advanced search
Evgenij LegotskojNov. 27, 2016, 11:13 p.m.

PyQt5PyQt5 - Lesson 003. QSystemTrayIcon - How to minimize application to tray

PyQt5, Pycharm, Qt, QSystemTrayIcon

Similar article on Qt/C++

One of the first articles on working with Qt has an article on working with QSystemTrayIcon . Now came the turn of the same material, but in Python using PyQt5 library.

This article will discuss how to write a simple application to PyQt5, which will be minimized to the system tray when you click a menu item in the system tray icon, or by pressing the close button.

Project structure in this case is minimal. There is only one file, which will be run. That is __main__.py file.

The application itself will be as follows.

If the checkbox is checked, the application will minimize to the system tray, otherwise the application will be terminated. In addition, it is possible to fold the application to the system tray using the context menu of the application icon in the system tray.

Evgenij LegotskojNov. 1, 2015, 11:39 p.m.

QMLQML - Lesson 008. How to work with system tray (QSystemTrayIcon)

QSystemTrayIcon, Qt, QML

When moving the application interface from Qt / C ++ to Qt / QML my hands reached and application icons in the system tray. The aim was to put an icon in the System Tray from C ++ to QML, partially or completely. The first option, which I realized, was a wrapper around QSystemTrayIcon with QMenu using a system of signals and slots . The solution is quite logical, given that in QML is not a facility, like MenuBar to System Tray. So we do a wrapper, which can interact in QML layer.

After the wrapper was implemented, I had the opportunity to consult with the programmer of Wargamming  - Constantine Lyashkevich , who recommended me to pay attention to what QML can have access not only to the signals and slots, and the parameters of the Q_PROPERTY , who also were in the class QSystemTrayIcon , that is, in fact it was only possible to register this class as the type layer in QML and try to write almost all the code on the QML. I checked the board and talked about by Constantine. As a result, he became interested in this problem and we spent the evening entertaining hour of attempts and jointly stuffed QSystemTrayIcon maximum in QML.

So in this article you will see two implementations to work with an icon in the system tray.

The resulting application will minimize to the System Tray by clicking the icon in the system tray, as well as by pressing the close button. But only in the event that will be active the special checkbox to control the folding process of the application window to the system tray, if the checkbox is not enabled, the application will be closed. Also, the application can be closed with an active checkbox menu item in the system tray icon.

Evgenij LegotskojAug. 12, 2015, 10:27 p.m.

QtQt/C++ - Lesson 002. QSystemTrayIcon - How to minimize the application to the system tray?

QSystemTrayIcon, Tray, qt, трей

Similar article on PyQt5/Python

Today will discuss the way to turn off the application, the Qt framework, written in, the operating system tray using QSystemTrayIcon class. This function is very useful for applications that need to run in the background for a long time mode. For example, video or audio playback application.

Therefore we will work with following questions:

  • How to teach your program minimized to tray;
  • How to make a popup menu for the tray icon of your applications;
  • How to disable this feature if it is not needed.
Timeweb

Let me recommend you the excellent hosting on which EVILEG is located.

For many years, Timeweb has been proving his stability.

For projects on Django I recommend VDS hosting

View Hosting
PH

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:60points,
  • Rating points-1
SN

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:10points,
  • Rating points-10
k
  • knobu
  • Sept. 23, 2020, 12:34 p.m.

C++ - Test 006. Enumerations

  • Result:60points,
  • Rating points-1
Last comments
DI

Qt/C++ - Lesson 015. QTableWidget – How to create a table with checkboxes?

Кто-нибудь знает, как сделать так, чтобы в QTableWidget состоящей из чекбоксов в строке таблицы можно было выбрать только один checkbox ?

Qt/C++ - Lesson 006. QSqlQueryModel – Tables in Qt with SQL-query

QSqlTableModel выполняет ряд стандартных операций для одной таблицы из базы данных. Поэтому там и реализован функционал по удалению и редактированию. QSqlQueryModel позволяет выполнить запр…
VB

Qt/C++ - Lesson 006. QSqlQueryModel – Tables in Qt with SQL-query

Добрый день. Хотел спросить вот что. Создал проект на основе QAbstractTableModel. В MainWindow cоответственно создал модель и связал с представлением. Поиск веду по списку элементов модели,…

QCheckBox в качестве делегата QTableView

До тех пор, пока у вас проект содержит только одну таблицу, или несколько то может быть. Когда их будет 1000 и чекбоксы в разных колонках, то без делегатов и переопределения возвращаемых ре…
D
  • Damir
  • Sept. 21, 2020, 1:34 a.m.

QCheckBox в качестве делегата QTableView

bool Node::setData(const QModelIndex& index, const QVariant& value, int role){ switch (index.column()) { case 0: switch (role) { case Qt::CheckStateRole:// <- т…
Now discuss on the forum

Как в Qt в qmenu добавить scrollarea

Вот это наследованный класс меню. Но посути это обычное меню. #pragma once#include <QtWidgets>class TransMenu : public QMenu { Q_OBJECTpublic: TransMenu(QWidget* parent = …
  • Nomad
  • Oct. 1, 2020, 3:22 p.m.

MyForm(forms.Form): - непонятка

понятно спасибо
DI

Как в QTableWidget, состоящей из чекбоксов, в строке таблицы можно было выбрать только один checkbox ?

Сделал таблицу состоящую из чекбоксов по уроку https://evileg.com/ru/post/78/ Кто-нибудь знает, как сделать так, чтобы в QTableWidget состоящей из чекбоксов в строке таблицы можно …
U

как скрыть елемент с копии виджета

Удалить пост нельзя... Поэтому удачки, Катту)
H

Тесты падают при сборке под MinGW.

Всем привет! При сборке под MinGW некоторые тесты при старте выдают FATAL "не удалось запустить тест проекта" и подвешивают Qt Creator - приходится его перезапускать. При сборке под MSVC та…
About
Services
© EVILEG 2015-2020
Recommend hosting TIMEWEB