简体   繁体   English

QSystemTrayIcon和Windows8

[英]QSystemTrayIcon and Windows8

I writing app and have strange bug in tray class. 我正在编写应用程序,并且在纸盒类中有奇怪的错误。 Inside my class I using QSystemTrayIcon like 在我的课堂中,我使用QSystemTrayIcon

 tray = new QSystemTrayIcon(this);
 tray->setIcon(QIcon(":/gui/logo.png"));
 ...
 tray->show();

On WinXP and Windows7 it's working properly, but on Windows 8 icon is not displayed WinXPWindows7它可以正常工作,但在Windows 8上,不显示图标

    qDebug()<<"System TRAY:"<< QSystemTrayIcon::isSystemTrayAvailable();// outputs true

I use Qt5.1.1 MSVC 2012 我使用Qt5.1.1 MSVC 2012

我只是遇到了同样的问题,我从phyatt使用的解决方案是将imageformats文件夹复制到我的应用程序的plugins文件夹中,并且现在工作正常。

Whether or not the system tray icon loads, I have found is more dependent on if it can load the file type. 我发现系统托盘图标是否加载,更多取决于它是否可以加载文件类型。

Is the appropriate plugin available in your deployment environment? 您的部署环境中是否提供适当的插件?

http://www.qtcentre.org/threads/43152-Deploying-Qt-Application-on-Windows-Load-JPG-Images-Problem http://www.qtcentre.org/threads/43152-Deploying-Qt-Application-on-Windows-Load-JPG-Images-Problem

http://qt-project.org/doc/qt-4.8/deployment-windows.html http://qt-project.org/doc/qt-4.8/deployment-windows.html

Hope that helps. 希望能有所帮助。

UPDATE: Qt 5.1 w/ msvc 2012 32bit test results of QSystemTrayIcon on Windows 8 Pro: Compiling and building the test application with the following in a stock UI Form project, with the following in the mainwindow.cpp 更新:Qt 5.1 w / msvc 2012 Windows 8 Pro上的QSystemTrayIcon 32位测试结果:编译和构建测试应用程序,并在库存UI Form项目中进行以下操作,其中在mainwindow.cpp中进行以下操作

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QSystemTrayIcon>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QSystemTrayIcon * sys = new QSystemTrayIcon(this);
//    sys->setIcon(QIcon("C:/Users/phyatt/Downloads/system-tray.png"));
    sys->setIcon(QIcon(":/gui/system-tray.png"));
    sys->show();
}

MainWindow::~MainWindow()
{
    delete ui;
}

And with these dependencies next to the exe, it runs just fine. exe旁边有这些依赖项,它运行得很好。

Qt 5.1依赖

截图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM