< Development‎ | Tutorials
Revision as of 10:14, 7 September 2006 by Danimo (talk | contribs)

Development/Tutorials/First program

Your first program

Your first program shall greet the world with a friendly "hello world", what else ? For that, we will use a KMessageBox. To get more information about the KMessageBox-Class, type "kde: kmessagebox" in your konqueror and it will redirect you to http://developer.kde.org/documentation/library/cvs-api/kdelibs-apidocs/kdeui/html/classKMessageBox.html <highlightSyntax language="cpp">

#include <QString>
#include <kapplication.h>
#include <kaboutdata.h>
#include <kmessagebox.h>
#include <kcmdlineargs.h> 

int main (int argc, char *argv[])
  KAboutData aboutData( "test", "test",
      "1.0", "test", KAboutData::License_GPL,
      "(c) 2006" );
  KCmdLineArgs::init( argc, argv, &aboutData );
  KApplication khello;
  KGuiItem kgi(QString("Hello"),QString(),
    QString("this is a tooltip"),QString("this is whatsthis"));

</highlightSyntax> If you set up your environment as in KDE3To4, you can compile this code with

gcc hello.cpp -o hello -I/home/kde-devel/qt-unstable/include/Qt  -I/home/kde-devel/qt-unstable/include/Qt-Core \
-I/home/kde-devel/qt-unstable/include -I/home/kde-devel/kde/include  -L/home/kde-devel/kde/lib \
-L/home/kde-devel/qt-unstable/lib -lkdeui -lkdecore -ldl      

and then run it with ./hello

Note: This page is about KDE 4. It isn't applicable for KDE 3 development.

This page was last edited on 8 September 2020, at 14:30. Content is available under Creative Commons License SA 4.0 unless otherwise noted.