You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Tuesday, August 24th 2004, 4:40pm

tray icon

Hello,
I made a small application for kde in linux that should run in the background and perform a specific task. Now I want to have a tray icon for it, like with sim,kopete kmix and so forth.

Can I do that with qt? What is the right way to get it work?

alex.

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

2

Tuesday, August 24th 2004, 10:00pm

Qt/KDE Developer
Debian User

3

Wednesday, August 25th 2004, 2:37pm

Hey, thanx. I guess that's what I need.

After executing qmake -project and qmake, I usually add to the Makefile the missing libraries of qt : -L/usr/share/qt3/lib -lqt-mt
What should be used for ksystemtray.h? I installed this library: kdelibs4-dev on debian, and I've found ksystemtray.h in /usr/include/kde

alex.

This post has been edited 3 times, last edit by "alexrait1" (Aug 25th 2004, 2:59pm)


4

Wednesday, August 25th 2004, 4:34pm

Ok, I found it. The library is kdeui. So I just had to write
-L/usr/lib/ -L/usr/lib/kde -lkdeui

But here it is, I get the program compiled at last, and it gives me a segmentation. In the documentation of KSystemTray it is written that the class behaves as a normal widget, so I add to my main widget constructor these lines
KSystemTray * ksys = KSystemTray(this,"ksys");
without it there is no problem, the application runs ok, but after this, the application crashes with segemntation fault....

Anyone had experience with ksystemtray before? maybe I am doing something wrong... Can it be some problem with debian packages?


alex.

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

5

Wednesday, August 25th 2004, 5:29pm

Quoted

Originally posted by alexrait1
After executing qmake -project and qmake, I usually add to the Makefile the missing libraries of qt : -L/usr/share/qt3/lib -lqt-mt


If the linker directives for Qt are missing in the Makefile, there is something wrong with your .pro file.
Perhaps you are missing "qt thread" in your CONFIG line?

Quoted

Originally posted by alexrait1
-L/usr/lib/ -L/usr/lib/kde -lkdeui

I think you also need -lkdecore

Quoted

Originally posted by alexrait1
But here it is, I get the program compiled at last, and it gives me a segmentation.


Do you have a QApplication instance in main() or a KApplication instance?
If the first, try using a KApplication

Cheers,
_
Qt/KDE Developer
Debian User

6

Wednesday, August 25th 2004, 6:02pm

Hey,
I opened a new standard qt project with kdevelop which includes QApplication instance in the main function and all the initiations are correct.
what does kdecore give to me? (the compilation succedes without it...).

Maybe I should use KApplication, but this class inherits from QApplication and the documentation states KSystemTray behaves like a normal widget....

Did you ever managed to run it (the system tray)?

alex

This post has been edited 1 times, last edit by "alexrait1" (Aug 25th 2004, 6:03pm)


7

Thursday, August 26th 2004, 9:53am

I solved it at last .

Indeed, KSystemTray doesn't work with qapplication class. It needs kapplication.
What I did is to replace the statement "QApplication a(argc,argv)" with KApplication a;
And in order to initialte it I added this line
KCmdLineArgs::init(argc, argv, aboutdata);
(aboutdata was defined too).

My question is what is going on here? Where did KCmd LineArgs::init(..) came from, I don't call for it's constructor anywhere. What I see is that there is another include to <kcmdlineargs.h>
How kapplication knows about it's existance?

Here is something similar to what I have:

http://perso.wanadoo.es/antlarr/tutorial/p9.html

In addition, the program would yield a segmentatioin fault if the KCmdLinArgs::init was omitted.

This post has been edited 1 times, last edit by "alexrait1" (Aug 26th 2004, 9:56am)


anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

8

Thursday, August 26th 2004, 4:50pm

Quoted

Originally posted by alexrait1
Indeed, KSystemTray doesn't work with qapplication class. It needs kapplication.

Unfortunately some of KDE's classes internally depend on KApplication.
I guess this is one of the candidates for changes when KDE4 is begin developed.

Quoted


My question is what is going on here? Where did KCmd LineArgs::init(..) came from, I don't call for it's constructor anywhere. What I see is that there is another include to <kcmdlineargs.h>
How kapplication knows about it's existance?

KCmdLineArgs handles this internally, I guess some kind of singleton.

Quoted


In addition, the program would yield a segmentatioin fault if the KCmdLinArgs::init was omitted.


I guess the docs should contain a warning that you really need to call KCmdLineArgs::init before.
Currently it only tells that to takes the additional paramaters from KCmdLineArgs.

Cheers,
Kevin
Qt/KDE Developer
Debian User