关于QWinJumpList和JumpList(QML)

About QWinJumpList

在这里插入图片描述

前言:最近发现桌面任务栏右键有个跳转菜单,这样固定到任务栏之后不需要点进去应用就可以实现一些功能,比如打开最近项目之类的。


简介:

  • Jump Lists是Windows 7开始引入的新功能,该功能允许用户查看固定在任务栏中程序最近打开的文件。
  • Jump Lists由应用软件或者系统创建,作用是方便用户可以直接跳转到最近打开的文件或文件夹。
  • Jump List显示的列表数量是有限的,在Windows 7/8操作系统中,用户可以通过更改注册表来修改Jump List的条数,但在Windows 10中,这个数量被固定了,用户无法自行修改。

Qt5

QGUI方案

My Kits:Qt5.15.2 MSVC2019/MinGW8.1.0 32/64bit

  • 首先工程文件中添加模块QT += winextras

  • 头文件:

    • #include <QWinJumpList>
    • #include <QWinJumpListCategory>
    • #include <QWinJumpListItem>
  • TestWinJumpList.h

  • #include <QObject>
    #include <QWinJumpList>
    #include <QWinJumpListCategory>
    #include <QWinJumpListItem>
    
    class TestWinJumpList : public QObject
    {
        Q_OBJECT
    public:
        explicit TestWinJumpList(QObject *parent = nullptr);
        ~TestWinJumpList();
        void showJumpList();
    private:
        QWinJumpListItem *jumpItem_m{(Q_NULLPTR)};
        QWinJumpList *jumpList_m{(Q_NULLPTR)};
    };
    
  • TestWinJumpList.cpp

  • #include "TestWinJumpList.h"
    
    TestWinJumpList::TestWinJumpList(QObject *parent)
        : QObject{parent}
    {
        jumpItem_m = new QWinJumpListItem(QWinJumpListItem::Link);
        jumpList_m = new QWinJumpList();
    
        jumpItem_m->setArguments(QStringList(QString("as")));
        jumpItem_m->setDescription("打开资源管理");
        jumpItem_m->setTitle("Open Explorer");
    
        jumpList_m->tasks()->setTitle("Title");
        jumpList_m->tasks()->addItem(jumpItem_m);
    }
    
    TestWinJumpList::~TestWinJumpList()
    {
        // the parent manage Class, so don't delete Qt's member
        // delete jumpItem_m;
        // delete jumpList_m;
    }
    
    void TestWinJumpList::showJumpList()
    {
        jumpList_m->tasks()->setVisible(true);
    }
    
  • main.cpp

  • QApplication app_(argc, argv);
    QWidget w;
    w.show();
    TestWinJumpList jumpList(&w);
    jumpList.showJumpList();
    return app_.exec();
    

参考链接:

QML方案

  • main.qml

  • import QtQuick.Window 2.15
    import QtQuick 2.15
    
    import "qrc:/CustomQmlModels/TestQMLModels"
    
    Window {
        id: root
        visible: true;
        width: 1280
        height: 720
    
        TestCustomJumpList {
            id: customJumpList_ID
            Component.onCompleted: {
                console.log("custom items:" + customJumpList_ID.categories.length);
                console.log("recent items:" + customJumpList_ID.recent.items);
                console.log("frequent items:" +customJumpList_ID.frequent.items);
            }
        }
    
        Component.onCompleted: {
            console.log("Hello World!");
        }
    }
    
  • TestCustomJumpList.qml

  • import QtQuick 2.15
    import QtWinExtras 1.15
    
    JumpList {
        id: jumpList_ID
        recent.visible: true
        frequent.visible: true
        tasks: JumpListCategory {
            xxxxxxx
        }
        
        JumpListCategory {
            xxxxxxx
        }
    }
    

Qt6

  • 18
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Taiga_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值