Beginning KDE Programming”
Total Page:16
File Type:pdf, Size:1020Kb
Beginning KDevelop Programming pseudonym67 Copyright (c) 2006 by pseudonym67. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, vX.Y or later (the latest version is presently available at http://www.opencontent.org/openpub/) About the Author Since becoming disabled from work and becoming practically house bound I have had a number of projects published on CodeProject. and have decided to play around with some stuff on Linux. All projects are the results of the few hours a day if any when I am neither asleep or ill and will hopefully continue to prevent me from climbing the walls. About This Project This project is the authors attempt to learn how to program using the KDE programming environment. It is by no means a C++ tutorial nor is it a general guide to setting up KDE in fact initially it wont even be a wide ranging look at KDE itself because the idea is to use a familiar environment to standard Windows programming which means that I will initially be concentrating on the Simple Designer Based KDE Application projects which is the KDE version of a rapid application development environment of the type that most windows programmers will be familiar with and will provide a less stressful introduction to Linux programming for people new to the KDE development environment. The idea is to provide a programming guide along the lines of the many Windows programming guides that can be found in any book shop, although being for Linux this guide will be freely available to all and as I am not being paid by the page it will not detail every single option like some books I could mention but will leave some of the details to the reader to discover. Requirements The project is developed using a standard set-up of Suse Linux 10 which comes with KDE 3. There will be no special settings or scripts to run basically if it doesn't work out of the box it wont be covered here. ( As with all rules there is an exception. This is the scripts used to set up MySQL ) Changes made through the use of the official Suse Updates that are downloaded through the Suse Watcher program are of course accepted. For people who are not as familiar with C++ as they would like to be or find they are having problems I'd recommend The C++ Programming Language or you could see what you can find on the web. Or you could just read the C++ Annotations book by Frank B. Brokken that comes as part of the KDevelop help documentation. On the whole we wont be using too much advanced C++ but readers should be familiar with at least function overloading, inheritance and constructors. All programs will be developed using the KDevelop KDE/C++ version of KDevelop. All other tools used will be part of the KDE setup so as long as KDE is installed they should be available on any Linux distribution. Release Schedule When there's something to release. Beginning KDevelop Programming KDE 3.x Version pseudonym67 [email protected] http://www.beginning-kdevelop-programming.co.uk/ Table of Contents Chapter 1 The Basics............................................................................................................................9 Version Control ...................................................................................................................14 Creating A Repository.....................................................................................................16 Viewing The Files...........................................................................................................18 Initialising The Repository..............................................................................................19 KDE Project Files.................................................................................................................20 The KDE Application Class.................................................................................................31 Summary..............................................................................................................................31 Chapter 2 The KDE Application........................................................................................................32 The Command Line..............................................................................................................33 Code Snippets.......................................................................................................................41 A Better Demonstration .......................................................................................................42 Coding Styles...................................................................................................................43 Adding The Demo Code..................................................................................................43 Debugging Code...................................................................................................................45 CVS The Easy Way..............................................................................................................52 Documentation.....................................................................................................................55 Generating The Documentation.......................................................................................60 Doxygen Options.............................................................................................................62 Generated Files.....................................................................................................................65 Summary..............................................................................................................................71 Chapter 3 Common Widgets..............................................................................................................72 Problems Building Forms.....................................................................................................82 Buttons..................................................................................................................................84 Tip Of The Day....................................................................................................................87 Boxes....................................................................................................................................88 Spacers..................................................................................................................................96 More On Layouts.............................................................................................................98 Edits....................................................................................................................................100 Tab Order.......................................................................................................................101 Chapter 4 Containers And Views.....................................................................................................103 Accelerators........................................................................................................................108 Graphical Connections.......................................................................................................108 The Views Demonstration .................................................................................................113 Adding Libraries To A Project .....................................................................................117 Selecting A Directory....................................................................................................122 Filling The Views..........................................................................................................124 Chapter 5 Database Programming With MySQL.............................................................................127 Order...................................................................................................................................127 1. Install My SQL..........................................................................................................127 2. MySQL_Install_DB...................................................................................................128 3. Start MySQL..............................................................................................................129 4. MySQL_Fix_Privilege_Tables..................................................................................130 5. Change Root Password..............................................................................................131 6. Uninstall MySQL......................................................................................................131 Using a DataTable..............................................................................................................146 Adding A Dialog...........................................................................................................146 Implementing The Dialog..............................................................................................154 Query The Database...........................................................................................................154 Tip Of The Day..................................................................................................................158 Using the DataBrowser......................................................................................................159