KStatusNotifierItem 实例化导致 Qt 崩溃



我正在使用带有Qt 5.11的Ubuntu Unity 17.04,并且在实例化KStatusNotifierItem时遇到Qt崩溃的问题。

这是我的包含文件:

QT += widgets
HEADERS       =    
SOURCES       = main.cpp
# LIBS
LIBS += -lkdeui
# install
target.path = $$[HOME]/KSNITester
INSTALLS += target

这是我的消息来源:

#include <QApplication>
#include "kstatusnotifieritem.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
KStatusNotifierItem * statusItem = new KStatusNotifierItem();
return a.exec();
}

当我运行时,我得到一个SIGSEGV,程序崩溃:

Starting /home/anshah/KSNITester/KSNITester...
The program has unexpectedly finished.
The process was ended forcefully.
/home/anshah/KSNITester/KSNITester crashed.

请让我知道如何解决此问题。

main.cpp:

#include <QApplication>
#include <QWidget>
#include <KStatusNotifierItem>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window;
KStatusNotifierItem *sni = new KStatusNotifierItem(&window);
sni->setCategory(KStatusNotifierItem::ApplicationStatus);
sni->setIconByName("face-smile");
sni->setTitle("KStatusNotifierItem Demo");
window.show();
return app.exec();
}

.pro 文件:

TEMPLATE = app
TARGET = ksnidemo
QT += widgets dbus KNotifications
SOURCES += main.cpp

相关内容

  • 没有找到相关文章