Sunday, January 21, 2007

Simple KDE4

I thought it was about time I got to know KDE4's libs better, so I started with the simplest programme I could - a hello world programme, and then extended it to start using kdelibs. So I made it produce an MD5 checksum of "Hello, world" as well. This way I didn't have to bother learning any GUI stuff - I could just concentrate on the very basic stuff. So here's what I wrote:

CMakeLists.txt:
project( test1 )
find_package( KDE4 REQUIRED )
include_directories( ${KDE4_INCLUDES} )

set( SRC test1.cpp )
kde4_automoc( ${SRC} )
kde4_add_executable( test1 ${SRC} )
target_link_libraries( test1 ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} )


test1.cpp
#include <KDE/KCodecs>
#include <QtCore>
#include <iostream>


int main(int argc, char *argv) {
KMD5 context( "Hello, world" );
std::cout << "Digest output: " << context.hexDigest().data() << std::endl;
}


Very simple - but now I can start experimenting with the other kdelibs classes until I understand them well. Then I will be able to understand the rest of KDE better.

No comments: