Privacy policyContactsAbout siteOpinionsGitHubDonate
© EVILEG 2015-2018
Recommend hosting

Using the capabilities of winExtras when working with QML

winextras, qt, qml, TaskbarButton, ThumbnailToolBar, JumpList

Some time ago I wrote several articles about using the QtWinExtras library, which opens access to special features that are available only for Windows. Now I want to say a few words about how to repeat, too, using QML. For this we need to create a Qt Quick project, connect the winextras module in the project

import QtWinExtras 1.0

And use 3 objects: TaskbarButton to create a progress bar and manage it, ThumbnailToolBar for work with buttons on the pop-up window of the taskbar and JumpList (for working with jumpList). Also add FileDialog for the full work of jumpList.

For TaskbarButton, you need to set the id properties (to access this object from outside), progress.visible: true. Additionally, you can set the overlay.iconSource icon.

In ThumbnailToolBar we create the ThumbnailToolButton (from one to seven) buttons, set the icons and write the click processing.

In JumpList, the recent section is visible to show the last opened files and frequent to display frequently opened files.

    JumpList {
        id: jumpList
        recent.visible: true
        frequent.visible: true

Do not forget that the file extensions that fall into the jumpList must be registered in the registry. Therefore, add the function associateFileTypes () to the main file, as shown in the previous article .

Another curious possibility is the setting of the transparency of the window. To do this, you need the DwmFeatures object. Its blurBehindEnabled property makes the window transparent if its value is true. If you set it to false, the background color becomes black. I also note that the transparency can be set using the opacity property of the Window object. It differs from blurBehindEnabled in that the latter can have only 2 states (transparent and opaque) and makes only the main part of the window transparent (without widgets placed on it), while opacity sets the degree of transparency and makes the whole window transparent with all the widgets And a frame. Another 4 leftGlassMargin, rightGlassMargin, topGlassMargin, and bottomGlassMargin properties are responsible for the size of the extra margin from the left, right, top, and bottom side of the window, respectively. Indentation values ​​are specified in pixels. The default values ​​are 0. I do not see the application application in these properties, but I wrote about them for completeness.


import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Controls 2.0
import QtQuick.Dialogs 1.0
import QtWinExtras 1.0

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello WinExtras")
    DwmFeatures {
        id: dwmFeatures
        blurBehindEnabled: true
        leftGlassMargin : 10
        rightGlassMargin : 10
        topGlassMargin : 10
        bottomGlassMargin : 10
        excludedFromPeek : false
        peekDisallowed : false
        flip3DPolicy: QtWin.FlipExcludeBelow

        height: 100
        text: "button"

    TaskbarButton {
        id: taskbarButton 
       //overlay.iconSource: "loading.png" 
       overlay.accessibleDescription: "Loading"
        progress.visible: true
        progress.value: 50

   ThumbnailToolBar {
        ThumbnailToolButton { iconSource: "r.png"; tooltip: "Next"; onClicked: taskbarButton.progress.value = taskbarButton.progress.value+1 } 
       ThumbnailToolButton { iconSource: "l.png"; tooltip: "Prep"; onClicked: taskbarButton.progress.value = taskbarButton.progress.value-1 }
        ThumbnailToolButton { iconSource: "pause.png"; tooltip: "Pause"; onClicked: taskbarButton.progress.setPaused(!taskbarButton.progress.paused) }
        ThumbnailToolButton { interactive: false; flat: true }
        ThumbnailToolButton { iconSource: "open.png"; tooltip: "OpenFile"; onClicked:}
        ThumbnailToolButton { iconSource: "exit.png"; tooltip: "Open"; onClicked: Qt.quit() }

    JumpList {
        id: jumpList 
       recent.visible: true 
       frequent.visible: true
        //tasks.visible: true 

    FileDialog {
          id: fileDialog
          selectFolder: true
          title: "Please choose a file"
          folder: shortcuts.home
          onAccepted: {
              console.log("You chose: " + fileDialog.fileUrls)


#include <QFileInfo>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QDir>
#include <QSettings>

static void associateFileTypes(const QStringList &fileTypes)
    QString displayName = QGuiApplication::applicationDisplayName();
    QString filePath = QCoreApplication::applicationFilePath();
    QString fileName = QFileInfo(filePath).fileName();
    //qDebug() << displayName << filePath << fileName;
    QSettings settings("HKEY_CURRENT_USER\\Software\\Classes\\Applications\\" + fileName, QSettings::NativeFormat);
    settings.setValue("FriendlyAppName", displayName);
    foreach (const QString& fileType, fileTypes)
        settings.setValue(fileType, QString());
    settings.setValue("FriendlyAppName", displayName);
    settings.setValue(".", QChar('"') + QDir::toNativeSeparators(filePath) + QString("\" \"%1\""));
int main(int argc, char *argv[])
    QGuiApplication app(argc, argv);
    app.setApplicationDisplayName("QtWinExtras Test");
    QQmlApplicationEngine engine;
    return app.exec();

Text of the program

Virtual hosting with 10 percent discount
Virtual hosting with 10 percent discount
EVILEG offers reliable hosting with a 10% discount for virtual hosting and 5% for VPS


Only authorized users can post comments.
Please, Log in or Sign up
April 21, 2019, 9:40 a.m.
Моисей Бушуев

Qt - Test 001. Signals and slots

  • Result:0points,
  • Rating points-10
April 17, 2019, 7:40 p.m.
Anton Ablin

Qt - Test 001. Signals and slots

  • Result:73points,
  • Rating points1
April 17, 2019, 6:16 p.m.

Qt - Test 001. Signals and slots

  • Result:100points,
  • Rating points10
Last comments
April 21, 2019, 4:22 p.m.
Евгений Легоцкой

Через метод setIcon table.horizontalHeaderItem(0).setIcon("qrc://path/to/icon.png")
April 21, 2019, 3:48 p.m.
Евгений Легоцкой

Добрый день! Спасибо за комментарий. Там действительно лучше будет сделать с инициализацией по умолчанию.
April 18, 2019, 3:37 p.m.

А как иконку в хедер задать?
April 18, 2019, 2:15 a.m.

доброго времени,большое спасибо за пример для начинающего)при адаптации к своему проекту столкнулся с таким ньансом:в vepolyline.h в 47 строке нужна инициализация по умолчанию: int m_pointF...
April 11, 2019, 12:49 p.m.

Спасибо за ответ) У меня компоновщик на нее ругался просто. Оказалось, просто забыл Q_OBJECT в начале класса указать.
Now discuss on the forum
April 24, 2019, 11:22 a.m.
Ruslan Polupan

Согласен. но ситуация не поменялась. Такое чуство что данные не записываются в модель.
April 24, 2019, 6:20 a.m.
Ruslan Polupan

я так понимаю надо инфорация об устройствах.Я бы пробовал так rust@suse:~> lsblk -PNAME="sda" MAJ:MIN="8:0" RM="0" SIZE="111,8G" RO="0" TYPE="disk" MOUNTPOINT=""NAME="sda1" MAJ:MIN="8...
April 21, 2019, 4:16 p.m.
Евгений Легоцкой

Приветствую Нужно сохранять где-то выбранное значение, а потом восстанавливать его. Или использовать QSettings или добавить метод open(), в который передавать начальные значения для того...
April 19, 2019, 9:55 a.m.

мені важко це зараз навіть перевірити, тому що знайшов коміт, це ще було в 2016 році, і цей код не буде працювати коректно зараз, єдине скажу що це були QThread
Join us in social networks

For registered users on the site there is a minimum amount of advertising