Using JumpList to store files opened in the application when using Qt

jumpList, winExtras


JumpList, one of the features that are present only in Windows (version 7 and above). In this sheet, in particular, you can store links to the most recently opened files in the application.

Step-by-step instruction

To use this function, you need to

Connect the module

QT += winextras

Connect library

#include <QtWinExtras>

Make the appropriate JumpList section active

QWinJumpList jumplist;

Associate all the required file extensions with our application using the function

static void associateFileTypes(const QStringList &fileTypes)
    QString displayName = QGuiApplication::applicationDisplayName();
    QString filePath = QCoreApplication::applicationFilePath();
    QString fileName = QFileInfo(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\""));

Which is convenient to use in the main

QApplication a(argc, argv);
a.setApplicationDisplayName("QtWinExtras Test");

Now when you open a new file, a link to it will be added to the last JumpList section.

When clicking on one of the links that appears, our application will start with the file name as the second parameter (argv [1]). With such a configuration, it is reasonable to modify the main function so that the selected file is opened.

if(argc == 2)[1]).replace(QString("\\"),QString("/")));

It is also possible to implement when, when the application is started, it is checked if there is a copy of it running. If such a copy is found, the application will send the name of the selected file to it and finish its work. I wrote the following implementation, where the name of the file is written to the registry.

    HANDLE hCorvetEvent = CreateEventA(NULL, FALSE, FALSE, ("winExJumpList"));
    if (GetLastError() ==  ERROR_ALREADY_EXISTS)
        if(argc == 2)
            QSettings *settings;
            settings = new QSettings("Company", "my programm");
            settings->setValue("AddFile", QString::fromLocal8Bit(argv[1]).replace(QString("\\"),QString("/") ) ); 
        return 0;

The program uses a timer-based function to monitor the registry change and open the added file.

connect(ui->pushButton, &QPushButton::clicked, this, &MainWindow::openFile);
    QTimer *openFile = new QTimer;
    connect(openFile, &QTimer::timeout, this, &MainWindow::nextFile);
void MainWindow::nextFile()
    QSettings *settings;
    settings = new QSettings("Company", "my programm");
    QString s = settings->value("AddFile").toString();
        settings->setValue("AddFile", "");

Of course, you will see the work of the program after you add the libraries necessary for the snack to the compiled exe-file.

Project with the source code of the program

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.
This is a nice start to learning how to use QWinJumplist but the demo files do not work when I try to load a file from the jump list Windows can't find the location of the file.

Unless I right click on the Recent items and select to open the txt file through a second context menu as opposed to a straight double click of the item.


Only authorized users can post comments.
Please, Log in or Sign up
How to become an author?

Contribute to the evolution of the EVILEG community.

Learn how to become a site author.

Learn it

Good day, Dear Users!!!

I am Evgenii Legotckoi, developer of EVILEG. And it is my hobby project, which helps to learn programming another programmers and developers

If the site helped you, and you want also support the development of the site, than you can donate by following ways


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 Timeweb
June 5, 2020, 2:28 a.m.

Qt - Test 001. Signals and slots

  • Result:0points,
  • Rating points-10
June 3, 2020, 1:56 a.m.

C++ - Тест 003. Условия и циклы

  • Result:35points,
  • Rating points-10
June 2, 2020, 9:11 p.m.
Aleksej Pikenin

C++ - Test 005. Structures and Classes

  • Result:75points,
  • Rating points2
Last comments
June 5, 2020, 1:39 a.m.
Evgenij Legotskoj

Qt/C++ - Tutorial 091. How to write a custom delegate controlling the highlighting of a row in a table

По-моему, смысла в этом нет особого. Если делегат будет игнорировать настройки таблицы, то это приведёт ещё к большему непониманию, что вообще происходит, для программиста, который после вас буд…
June 5, 2020, 1:34 a.m.

Qt/C++ - Tutorial 091. How to write a custom delegate controlling the highlighting of a row in a table

Сижу, размышляю: можно ли переписать делегата так, чтобы независимо от настроек строк выделялись строки?
June 5, 2020, 1:31 a.m.
Evgenij Legotskoj

Qt/C++ - Tutorial 091. How to write a custom delegate controlling the highlighting of a row in a table

Понятно. Я не обратил внимания на то, что там было в старом коде по настройкам строк :)
June 5, 2020, 1:27 a.m.

Qt/C++ - Tutorial 091. How to write a custom delegate controlling the highlighting of a row in a table

Разобрался. У вас изначально в проекте были вот эти настройки: ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);ui->tableView->setSelectionMode(QAbstractItemVie…
June 4, 2020, 11:10 a.m.

Qt/C++ - Tutorial 091. How to write a custom delegate controlling the highlighting of a row in a table

Полностью скопировал пример - всё правильно работает. Значит, где-то у меня ошибки в тестовом проекте. Буду разбираться. Извините за беспокойство. :)
Now discuss on the forum
June 5, 2020, 6:13 a.m.

Фильтр для QtableView sql

Добрый день. Для такой фильтрации необходимо использовать QSortFilterProxyModel. В оффдоках есть хороший пример.
June 4, 2020, 2:46 a.m.
Mihail A

Qt- C++ QTableView подсветить строку

June 3, 2020, 1:49 a.m.

Можно ли сделать в QML таблицу как в Excel?

edi-tableview - нашел пока такое выглядит коряво, посмотрим что можно сделать
June 2, 2020, 2:46 a.m.
Evgenij Legotskoj

Медиа файлы Google Firebase

Картинки можете попробовать сжимать через QPixmap, там есть возможность установки scaleFactor, через него можете устанавливать нужные параметры. А что касается конвертации видео, то лучше п…
June 2, 2020, 2:01 a.m.
Evgenij Legotskoj

Перехват обращения к локальным файлам QWebEngineView

В вашем случае вполне адекватное решение. Так сказать меньше зло. В противном случае пришлось бы очень много переписывать и перепиливать.
© EVILEG 2015-2020
Recommend hosting TIMEWEB