gpt4 book ai didi

c++ - QSystemTrayIcon 并不总是出现

转载 作者:太空狗 更新时间:2023-10-29 12:33:52 24 4
gpt4 key购买 nike

我编写了一个小程序来在合成器(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");

}

最佳答案

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

我还有:带有 Xfce 的 Manjaro Linux 64bit

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

关于c++ - QSystemTrayIcon 并不总是出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18287410/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com