KStatusNotifierItem实例化使Qt崩溃

时间:2018-10-22 18:23:28

标签: qt sigsegv kde

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

这是我的包含文件:

    trs.append("th")
      .text(function(d) { return d.index; })
      .attr("scope","row")

    trs.selectAll('td')
      .data(function(d){ return [d['Total'],    d['PRIMARY Alcohol only'],  d['Alcohol with secondary drug'],   d['Heroin'],    d['Other opiates'], d['Cocaine (smoked)'],  d['Cocaine (other route)'], d['Marijuana'], d['Amphetamines'],  d['Other stimulants'],  d['Tranquilizers'], d['Sedatives'], d['Hallucinogens'], d['PCP'],   d['Inhalants'], d['Other/Unknown']]; })
      .enter()
      .append('td')
      .text(function(d){
        return d;
      });

这是我的出处:

QT += widgets

HEADERS       =    
SOURCES       = main.cpp

# LIBS
LIBS += -lkdeui

# install
target.path = $$[HOME]/KSNITester
INSTALLS += target

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

#include <QApplication>
#include "kstatusnotifieritem.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    KStatusNotifierItem * statusItem = new KStatusNotifierItem();
    return a.exec();
}

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

1 个答案:

答案 0 :(得分:0)

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