The same thing now with a table
Example 4-2. Using a table
1 #include <kapp.h> 2 #include <kaboutdata.h> 3 #include <kcmdlineargs.h> 4 #include <klocale.h> 5 #include <hk_classes.h> 6 #include <iostream> 7 #include <hk_kdetable.h> 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 23 hk_kdetable* table = new hk_kdetable(NULL); 24 25 app.setMainWidget(table); 26 set_kdestandarddialogs(); 27 hk_drivermanager* mydrivermanager = new hk_drivermanager(false); 28 if (mydrivermanager==NULL) {cout <<"error creating mydrivermanager"<<endl;exit(1);} 29 hk_connection* myconnection = mydrivermanager->new_connection("mysql"); 30 if (myconnection==NULL) {cout <<"error creating myconnection"<<endl;exit(1);} 31 myconnection->connect(); 32 33 hk_database* mydatabase=myconnection->new_database("exampledb"); 34 if (mydatabase==NULL) {cout <<"error creating mydatabase"<<endl;exit(1);} 35 hk_datasource* mydatasource= mydatabase->new_table("authors"); 36 if (mydatasource==NULL) {cout <<"error creating mydatasource"<<endl;exit(1);} 37 38 table->set_datasource(mydatasource); 39 table->set_viewmode(); 40 table->show(); 41 42 int res= app.exec(); 43 delete mydrivermanager; 44 return res; 45 } |