加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

如何在Windows 7任务栏中显示进度(使用Qt)?

发布时间:2020-12-13 21:11:35 所属栏目:Windows 来源:网络整理
导读:原文转载于:https://cloud.tencent.com/developer/ask/120278 你可以使用这个 QWinTaskbarProgress 类。要使用这个类,你需要添加 win32:QT += winextras 你的.pro文件。 下面是一个示例代码,演示如何 QProgressBar 在Windows任务栏中显示a的值(从此示例中

原文转载于:https://cloud.tencent.com/developer/ask/120278

你可以使用这个QWinTaskbarProgress类。要使用这个类,你需要添加win32:QT += winextras你的.pro文件。

下面是一个示例代码,演示如何QProgressBar在Windows任务栏中显示a的值(从此示例中得到启发):

#ifdef _WIN32    //The _WIN32 macro is automatically generated when compiling for Windows
    #include <QWinTaskbarProgress>
    #include <QWinTaskbarButton>
#endif
QProgressBar *progressBar = new QProgressBar;
progressBar->show();
#ifdef _WIN32
    QWinTaskbarButton *windowsTaskbarButton new QWinTaskbarButton;    //Create the taskbar button which will show the progress
    windowsTaskbarButtonsetWindow(progressBarwindowHandle//Associate the taskbar button to the progress bar,assuming that the progress bar is its own window
    QWinTaskbarProgress *windowsTaskbarProgress = windowsTaskbarButtonprogress;
    windowsTaskbarProgress;
    QObject::connect(loadingWindow, &QProgressBar:valueChanged[windowsTaskbarProgress](int value{
        windowsTaskbarProgresssetValue(value;   //Change the value of the progress in the taskbar when the value of the progress bar changes
    };
#endif

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读