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, March 29th 2005, 9:50pm

need help, i cant describe my problem, sorry

i want to learn sth about qt.
my problem is, that alway i want to add sth. in the main.cpp of my qt-designer project( for example):

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <kapplication.h>
#include <ksystemtray.h>
#include <kcmdlineargs.h>

#include "form1.h"

int main( int argc, char ** argv )
{
KCmdLineArgs::init(argc, argv, "keagle", "keagle", "0.1");
KApplication a;
Form1 w;
a.setMainWidget(&w);
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );

KSystemTray* trayicon;
trayicon = new KSystemTray(this, "kashmere outpost");
//.... aso
return a.exec();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
i get this error
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
root@localhost DSLeagle # make
qmake -o Makefile keagle.pro
g++ -c -pipe -Wall -W -O2 -g -march=i686 -mtune=i686 -DQT_NO_DEBUG -DQT_SHARED-DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT -I/usr/lib/qt-3.3/mkspecs/default -I. -I/opt/kde3/include -I/usr/lib/qt-3.3/include -I.ui/ -I. -I.moc/ -o .obj/main.o main.cpp
main.cpp: In function `int main(int, char**)':
main.cpp:9: Warnung: »init« ist veraltet (deklariert bei /usr/include/kcmdlineargs.h:260)
main.cpp:17: Fehler: invalid use of `this' in non-member function
make: *** [.obj/main.o] Fehler 1
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

the same code in the form1.ui.h header:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Form1::show_Tray()
{
KSystemTray* trayicon;
trayicon = new KSystemTray(this, "????");

//if(status_connection() == 'r')
trayicon->setPixmap(QPixmap("network_traffic.png"));
//else trayicon->setPixmap(QPixmap("network_connected.png"));

if(!trayicon->isVisible())
trayicon->show();

if (trayicon->isVisible())
hide();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
...is working???
my main goal is it to add a simple tray icon to the system tray, when the prog starts.
for example this code is working to:

#include <qapplication.h>
#include <qlabel.h>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt!", 0);
app.setMainWidget(label);
label->show();
return app.exec();
}

sorry for bad english. mfg dgrat

wysota

Trainee

Posts: 65

Location: Warsaw, POLAND

  • Send private message

2

Tuesday, March 29th 2005, 9:54pm

This is not Designer related, moving to KDE Development.
Live and let live - use the search engine.
"Use the docs Luke, use the docs!"

3

Wednesday, March 30th 2005, 9:44am

uups wusst ich nicht...

jacek

Trainee

Posts: 105

Location: Warsaw, Poland

Occupation: Student

  • Send private message

4

Wednesday, March 30th 2005, 12:23pm

RE: need help, i cant describe my problem, sorry

Quoted

Originally posted by dgrat
int main( int argc, char ** argv )
{
...
trayicon = new KSystemTray(this, "kashmere outpost");
...
}
main.cpp:17: Fehler: invalid use of `this' in non-member function


You can use "this" keyword only in methods of some class. "main" function is just an ordinary function --- it doesn't belong to any class, so value of "this" is undefined. In this case you should probably use "&w" instead.

wysota

Trainee

Posts: 65

Location: Warsaw, POLAND

  • Send private message

5

Wednesday, March 30th 2005, 8:16pm

RE: need help, i cant describe my problem, sorry

This is a double (http://www.qtforum.org/thread.php?threadid=10196). I'm closing this thread.
Live and let live - use the search engine.
"Use the docs Luke, use the docs!"