Hi I'm designing an application platform and want to integrate Linux in particular for the KDE desktop only independent bookstores that if I use KDE and the QT libraries the look and feeling not like and I have all the power of the KDE libraries.
The problem is, I want to be an application platform that includes the libraries to compile only if I am using KDE and put what I have in KDE systray in the qt libraries since the application I'm designing on the qt.
When you run the code I get a Segmentation fault (`core 'generated)
I will also put your debug gdb
PD: In the pastebin is the header and also is in the pastebin the function that position in the implementation below setupui ();
#include "mainwindowimpl.h"
#include <QSystemTrayIcon>
#include <QDebug>
#include <ksystemtrayicon.h>
#ifdef Q_WS_X11
QString *OS=new QString("Linux");
#include <stdlib.h>
#endif
void MainWindowImpl::CreateSysTray()
{
if(OS->operator==("Linux") ) {
qDebug() << tr("Detected Linux in computer system.");
QString Detected = "true";
char *a=getenv ( "KDE_FULL_SESSION" );
if ( a )
Detected = a; //FIXME 1
if(Detected=="true"){
KSystemTrayIcon *tray = new KSystemTrayIcon("Test",this);
tray->setIcon(QIcon("./icons/icon.png"));
tray->show();
}
};
connect(tray, SIGNAL ( activated( KSystemTrayIcon::ActivationReason ) ), this, SLOT ( sysmtray_activado(KSystemTrayIcon::ActivationReason) ) );
}
void MainWindowImpl::iconActivated(KSystemTrayIcon::ActivationReason reason)
{
switch (reason) {
case KSystemTrayIcon::Trigger:
case KSystemTrayIcon::DoubleClick:
break;
case KSystemTrayIcon::MiddleClick:
break;
default:
;
}
}
//---------------------------------------@The header@
#ifndef MAINWINDOWIMPL_H
#define MAINWINDOWIMPL_H
//
#include <QMainWindow>
#include "ui_mainwindow.h"
#include <QSystemTrayIcon>
#include <ksystemtrayicon.h>
//
class QAction;
class MainWindowImpl : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT
public:
MainWindowImpl( QWidget * parent = 0, Qt::WFlags f = 0 );
private:
void createActions();
void CreateSysTray();
QAction *aboutQtAction;
KSystemTrayIcon *tray;
QAction *minimizeAction;
QAction *maximizeAction;
QAction *restoreAction;
QAction *quitAction;
private slots:
void AboutQT();
void AboutAlesan();
void iconActivated(KSystemTrayIcon::ActivationReason reason);
protected:
void closeEvent( QCloseEvent *event );
};
#endif
[Thread debugging using libthread_db enabled]
(30306) KSharedDataCache::Private::mapSharedMemory: Opening cache "/var/tmp/kdecache-alejandro/icon-cache.kcache" page size is 4096
(30306) KSharedDataCache::Private::mapSharedMemory: Attached to cache, determining if it must be initialized
(30306) KSharedDataCache::Private::mapSharedMemory: Cache fully initialized -- attached to memory mapping
(30306) KSharedDataCache::Private::mapSharedMemory: 4370432 bytes available out of 10485760
"Detected Linux in computer system."
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6796d0a in QObject::connect(QObject const*, char const*, QObject const*, char const*, Qt::ConnectionType) () from /usr/lib/libQtCore.so.4