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