【问题标题】:QSystemTrayIcon doesn't always show upQSystemTrayIcon 并不总是出现
【发布时间】:2013-08-17 09:49:50
【问题描述】:

我编写了一个小程序来在合成器(xfwm4、dcompmgr、cairo-compmgr)之间切换,以帮助解决在 nVidia 上可以体验到的视频撕裂。它在系统托盘中创建一个具有其操作的图标。问题是当我运行我的程序时图标并不总是出现,并且在我切换到不同的合成器后它消失了。我已经在一个可以在这里看到的视频中捕捉到它: https://www.youtube.com/watch?v=31qqOiaOdfw

我正在使用: 带有 Xfce 的 Manjaro Linux 64 位
QtCreator v.2.8.0 与 Qt 5.1

有人可以帮我解决这个问题吗?

compSwitcher.cpp

#include "compswitcher.h"
#include "ui_compswitcher.h"
#include <QMenu>
#include <QCloseEvent>
#include <QDebug>

compSwitcher::compSwitcher(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::compSwitcher)
{
    ui->setupUi(this);

    createActions();
    createIcon();
    setIcon();
    qDebug() << "Before trayIcon->show()\n";
    trayIcon->show();
    qDebug() << "After trayIcon->show()";

}

compSwitcher::~compSwitcher()
{
    delete ui;
    delete trayIcon;
    delete menu;
    delete xfwm4;
    delete close;
    delete dcompmgr;
}

void compSwitcher::createActions()
{
    close = new QAction(tr("&Quit"),this);
    QObject::connect(close, SIGNAL(triggered()), this, SLOT(endProgram()));

    xfwm4 = new QAction(tr("&xfwm4"), this);
    connect(xfwm4, SIGNAL(triggered()), this, SLOT(setXfwm4()));

    dcompmgr = new QAction(tr("&dcompmgr"), this);
    connect(dcompmgr, SIGNAL(triggered()), this, SLOT(setDcompmgr()));

    cairo = new QAction(tr("&cairo-compmgr"), this);
    connect(cairo,SIGNAL(triggered()), this, SLOT(setCairo()));
}

void compSwitcher::createIcon()
{
    menu = new QMenu(this);
    menu->addAction(xfwm4);
    menu->addAction(dcompmgr);
    menu->addAction(cairo);
    menu->addSeparator();
    menu->addAction(close);

    trayIcon = new QSystemTrayIcon(this);
    trayIcon->setContextMenu(menu);

}

void compSwitcher::setIcon()
{
    QIcon ikona(":/new/prefix1/kuba_fan1.png");
    trayIcon->setIcon(QIcon(ikona));

}

void compSwitcher::setXfwm4()
{
    system("/home/dec/Programowanie/qt/compSwitcher/skrypty/xfwm4true.sh");
}

void compSwitcher::setDcompmgr()
{
    system("/home/dec/Programowanie/qt/compSwitcher/skrypty/dcompmgr.sh");
}

void compSwitcher::setCairo()
{
    system("/home/dec/Programowanie/qt/compSwitcher/skrypty/cairo.sh");

}

【问题讨论】:

    标签: c++ linux qt xfce


    【解决方案1】:

    我遇到了类似的问题,在我的情况下,托盘从未显示。

    我还有:Manjaro Linux 64bit with Xfce

    我通过将面板更改为 tint2 来解决它。我认为这是xfce-panel的问题。

    【讨论】:

      猜你喜欢
      • 2010-12-02
      • 1970-01-01
      • 2022-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多