To get the all messages, warnings and dialogs away from the console to KDE use the function set_kdestandarddialogs() and include its header file hk_kdemessages.h.
Example 2-1. Getting the messages to KDE
1 #include <kapp.h> 2 #include <kaboutdata.h> 3 #include <kcmdlineargs.h> 4 #include <klocale.h> 5 #include <qwidget.h> 6 #include <hk_classes.h> 7 #include <iostream> 8 #include <hk_kdemessages.h> 9 10 static const char *description = 11 I18N_NOOP("A hk_kdeclasses example Application"); 12 13 static const char *version = "v0.1"; 14 15 16 int main(int argc, char **argv) 17 { 18 KAboutData about("hk_kdeexample", I18N_NOOP("hk_kdeexample"), version, description, KAboutData::License_GPL, "(C) 2001 Horst Knorr", 0, 0, "hk_classes@knorrnet.de"); 19 about.addAuthor( "Horst Knorr", 0, "hk_classes@knorrnet.de" ); 20 KCmdLineArgs::init(argc, argv, &about); 21 KApplication app; 22 QWidget* widget = new QWidget; 23 app.setMainWidget(widget); 24 set_kdestandarddialogs(); 25 26 hk_drivermanager* mydrivermanager = new hk_drivermanager(false); 27 if (mydrivermanager==NULL) {cout <<"error creating mydrivermanager"<<endl;exit(1);} 28 hk_connection* myconnection = mydrivermanager->new_connection(); 29 if (myconnection==NULL) {cout <<"error creating myconnection"<<endl;exit(1);} 30 myconnection->connect(); 31 32 hk_database* mydatabase=myconnection->new_database("exampledb"); 33 if (mydatabase==NULL) {cout <<"error creating mydatabase"<<endl;exit(1);} 34 hk_datasource* mydatasource= mydatabase->new_table("authors"); 35 if (mydatasource==NULL) {cout <<"error creating mydatasource"<<endl;exit(1);} 36 mydatasource->enable(); 37 38 widget->show(); 39 40 int res= app.exec(); 41 delete mydrivermanager; 42 return res; 43 } 44 |
Compile the program. Now you see a driver selection window followed by a login window. If you already have some experience with knoda you should recognize the dialogs.