License GNU General Public License, version 2
Lines 39
Keywords
gui (8) Hello World (24) KDE (1)
Included in this Library
Permissions
Owner: Stou S.
Viewable by Everyone
Editable by All Siafoo Users
Hide
Easily highlight source code for your blog with our Syntax Highlighter. Join Siafoo Now or Learn More

KDE Hello World Atom Feed 0

In Brief The minimal KDE application. If you plan on developing with KDE, you should definitely look at the excellent tutorials on the KDE site http://techbase.kde.org/Development/Tutorials/... more
# 's
 1#include <KApplication>
2#include <KAboutData>
3#include <KCmdLineArgs>
4#include <KMessageBox>
5
6int main (int argc, char *argv[])
7{
8 KAboutData aboutData(
9 // The program name used internally.
10 "hellokde",
11 // The message catalog name
12 // If null, program name is used instead.
13 0,
14 // A displayable program name string.
15 ki18n("KDE Hello World"),
16 // The program version string.
17 "1.0",
18 // Short description of what the app does.
19 ki18n("Displays a KMessageBox popup"),
20 // The license this code is released under
21 KAboutData::License_GPL,
22 // Copyright Statement
23 ki18n("(c) 2007"),
24 // Optional text shown in the About box.
25 // Can contain any information desired.
26 ki18n("Some text..."),
27 // The program homepage string.
28 "http://techbase.kde.org/Development/Tutorials",
29 // The bug report email address
30 "submit@bugs.kde.org");
31
32 KCmdLineArgs::init( argc, argv, &aboutData );
33 KApplication app;
34 KGuiItem yesButton( i18n( "Hello" ), QString(),
35 i18n( "This is a tooltip" ),
36 i18n( "This is a WhatsThis help text." ) );
37 KMessageBox::questionYesNo( 0, i18n( "Hello World" ),
38 i18n( "Hello" ), yesButton );
39}

The minimal KDE application. If you plan on developing with KDE, you should definitely look at the excellent tutorials on the KDE site http://techbase.kde.org/Development/Tutorials/

To build the app, download the source, create a cmake file named CMakeList.txt with the following contents:

# 's
1project (hellokde)
2
3find_package(KDE4 REQUIRED)
4include_directories(${KDE4_INCLUDES})
5
6set(hello_kde_SRCS hello_kde.cpp)
7
8kde4_add_executable(hellokde ${hello_kde_SRCS})
9target_link_libraries(hellokde ${KDE4_KDEUI_LIBS})

You can compile the code manually with a gcc command (which I never got to work actually) but if you are writing an actual application, you should take the time to create a make file anyway... since it will save you time later.

Then execute:

mkdir build && cd build cmake .. make

Then to run it simply type:

./hellokde