Next Previous Contents

8. Using KDevelop and QT-Designer

This chapter describes how to use kdevelop 2.1.5 with integrated cross compiling features and QT-Designer. If you have an older version, you should update to 2.1.5. QT-Designer has to be a 2.x version. QT-Designer 3.x delivers different outputs which are not compilable by uic2.

We will explain the usage of kdevelop using a standard kdevelop project as an example. This may not be very usefull first, but guarantees the correct creation of all kdevelop relevant scripts / files.

After the first steps are compilable (x11, emb, arm), we will extend that standard project with some new Dialog Elements using QT-Designer.

This chapter will close with the description of automated ipkg-creation. For that I use a set of bash/perl-scripts to create the ipkg. I will describe the usage and installation of that scripts (and the ipkg-build tool).

Least but not last the next chapter OPIE Tutorial will explain how to go on with the kdevelop sources to get them OPIE-ready.

Hint
I did not really test Gideon (3.x). Min. under Debian it seems to conflict with kdevelop 2.1.5, which is the reason I did not test it yet. Beside that I did not yet find an easy way to transfer 2.1.x projects to 3.x. As I want to wok on my projects, I still stay on 2.1.5.

8.1 Principles

In principle kdevelop uses the already known environmentscripts from above for crosscompilation. Some of the environment variables have to be fead into kdevelops setup entries to create different targets.

Configured with that environment scripts, kdevelop is able to use crosscompilers and create output for different targets. We will handle qt-embedded (x11) as a cross-target as well, as it uses a different qte version (and different opie).

8.2 Setup basics

The menu options/kdevelop setup/compiler allows the user to define the cross compilation tools. Assuming you have a i386 as the host, you can choose the build system as i386, linux and the target compile system as an arm, linux.

I have the following entries filled in (is this way installed as standard).


Attention
Dont use special characters to name your target system (e.g. blanks, ... ), because kdevelop works, but destroys the *.kdevses file. I did not do this my own, but got an email from a user who went into this trap. I am not sure, whether this bug is still existing. Just in case ;-).

8.3 Create the test project

We know will create a test application called testopie. Leave kdevelop, open an x-terminal and change to qtx11 environment. Start kdevelop from here kdevelop &. The environment guarantees that kdevelop finds all needed libs/paths.

Enter the menu project/new and select Qt-SDI from the upcoming list. Select Next, enter the Project-Name testopie and press Create (dont care for the other options and CSV for the moment).

KDevelop will create a subdir called testopie in your development (home) dir, which contains all relevant data. (The source files are found in testopie/testopie dir). You maybe will get an error like shown below.


Ignore that for now. KDevelop will try to create its templates using QT3. In my case this is not reachable by the normal QTDIR entry. So I (and maybe also you) will get that error.

Press Exit to finalize your project. Before we are able to compile the X version, we have to setup some more config entries.

For this enter the menu project/options and select Configure-Settings from the upcoming list. Enter QT/KDE-Version 2 in the appropriate field. Select Compiler-Options now from the list and choose the tab-entry Configure. Insert (overwrite) /usr/lib/qt2 into the --with-qt-dir field. The other entries may stay, as they are for now. Press OK and confirm the configure regeneration. Wait until that process has finished. Press <F9> now to build and start your application.

Here we have the result.


8.4 Prepare kdevelop for Embedded use

Just switch to qtemb environment and start kdevelop from the shell.

To prepare for emb crosscompiling, follow the steps below.

  1. Enter the menu project/options and choose compiler setup.
  2. Overwrite the Text (Standard) in the "Configuration" combo box with emb instead. Press the Add button right of that. This will enable the build-dir field. You can chage it or let as it is. Kdevelop chooses the dir ../emb to store the result.
  3. Choose the tab page Flags and Warnings. Choose Wall as compiler warnings and enter $OPTIONS $EXTRA_INC_PATH into the CXXFLAGS field (They were wanted in CPPFLAGS in kdevelop versions before).
    Note, that kdevelop is able to decode environment variables (coming from your environment scripts) in this field.
  4. Choose the tab page Linker Flags. Enter $EXTRA_LIB_PATH Additional Flags field (environment variable).
  5. Choose the tab page Configure. Enter /usr/lib/qt2opie-emb into the --with-qt-dir field and --enable-embedded --enable-qtopia into the Additional Options field.
  6. Choose the menu entry linker-options. Enter $(LIB_QPE) $(KDEVXT_LIB) into the additional library field.
    Note, that it is immediately necessary to use an environment variable ($(KDEVXT_LIB)) here, as the linker tab page dont differt between the different targets. That was not possible with the kdevelop versions before 2.1.5.
  7. Pressing the OK-button will start the configure script and cause an error. Dont be frustrated, everything is OK so far (see the error message below).

  8. KDevelop has a new combobox (second ToolBar line, very left). Here you can choose, which target you want to compile. Choose standard first, and select from the menu build/distclean.
    Note, that you have to do that always, when you changed between two targets.
  9. To get another target (here emb) compiled select emb from the combobox. Now you have to select from the menu build/autoconf and automake and afterwards build/configure (Confirm the configure-options as presented). Afterwards, you should have the program prepared for embedded compilation.
  10. Compile your test program now for embedded use. It will not compile because the standard QT-SDI requires some QT-LIB functions not supported by QT-Embedded.

    Just enter the file testopie.cpp (or doubleclick the error message) and uncomment the regarded stuff.
    void TestopieApp::slotFileOpen()
    {
      statusBar()->message(tr("Opening file..."));
    
    /*
      QString fileName = QFileDialog::getOpenFileName(0,0,this);
      if (!fileName.isEmpty())
      {
        doc->load(fileName);
        setCaption(fileName);
        QString message=tr("Loaded document: ")+fileName;
        statusBar()->message(message, 2000);
      }
      else
      {
        statusBar()->message(tr("Opening aborted"), 2000);
      }
    */
    }
            
    
    void TestopieApp::slotFileSaveAs()
    {
      statusBar()->message(tr("Saving file under new filename..."));
    /*
      QString fn = QFileDialog::getSaveFileName(0, 0, this);
      if (!fn.isEmpty())
      {
        doc->saveAs(fn);
      }
      else
      {
        statusBar()->message(tr("Saving aborted"), 2000);
      }
    */
    
      statusBar()->message(tr("Ready."));
    }
            
    
    void TestopieApp::slotFilePrint()
    {
      statusBar()->message(tr("Printing..."));
    /*
      QPrinter printer;
      if (printer.setup(this))
      {
        QPainter painter;
        painter.begin(&printer);
    
        ///////////////////////////////////////////////////////////////////
        // TODO: Define printing by using the QPainter methods here
    
        painter.end();
      };
    */
    
      statusBar()->message(tr("Ready."));
    }
            
    
  11. Recompile the program now and you will have success with compilation.

    But that is not yet what you need. You created a qapplication instead of an qpeapplication (needed for opie use).
  12. To change that, you have to adopt the main.cpp. The next paragraph shows the original created by the kdevelop template.
    /***************************************************************************
                              main.cpp  -  description
                                 -------------------
        begin                : Sam Aug 30 10:13:44 CEST 2003
        copyright            : (C) 2003 by Werner Schulte
        email                : werner@schulte-ac.de
     ***************************************************************************/
    
    /***************************************************************************
     *                                                                         *
     *   This program is free software; you can redistribute it and/or modify  *
     *   it under the terms of the GNU General Public License as published by  *
     *   the Free Software Foundation; either version 2 of the License, or     *
     *   (at your option) any later version.                                   *
     *                                                                         *
     ***************************************************************************/
    
    #include <qapplication.h>
    #include <qfont.h>
    #include <qstring.h>
    #include <qtextcodec.h>
    #include <qtranslator.h>
    
    #include "testopie.h"
    
    int main(int argc, char *argv[])
    {
      QApplication a(argc, argv);
      a.setFont(QFont("helvetica", 12));
      QTranslator tor( 0 );
      // set the location where your .qm files are in load() below as the last parameter instead of "."
      // for development, use "/" to use the english original as
      // .qm files are stored in the base project directory.
      tor.load( QString("testopie.") + QTextCodec::locale(), "." );
      a.installTranslator( &tor );
      /* uncomment the following line, if you want a Windows 95 look*/
      // a.setStyle(WindowsStyle);
    
      TestopieApp *testopie=new TestopieApp();
      a.setMainWidget(testopie);
    
      testopie->show();
    
      return a.exec();
    }
            
    
    The next paragraph shows the modified main.cpp. Modified lines are embraced by
    /**------...-----**/
    lines.
    /***************************************************************************
                              main.cpp  -  description
                                 -------------------
        begin                : Sam Aug 30 10:13:44 CEST 2003
        copyright            : (C) 2003 by Werner Schulte
        email                : werner@schulte-ac.de
     ***************************************************************************/
    
    /***************************************************************************
     *                                                                         *
     *   This program is free software; you can redistribute it and/or modify  *
     *   it under the terms of the GNU General Public License as published by  *
     *   the Free Software Foundation; either version 2 of the License, or     *
     *   (at your option) any later version.                                   *
     *                                                                         *
     ***************************************************************************/
    
    /** --------------------------------------- **/
    #ifndef QWS
    #include <qapplication.h>
    #else
    #include <qpe/qpeapplication.h>
    #endif
    // #include <qapplication.h>
    /** --------------------------------------- **/
    
    #include <qfont.h>
    #include <qstring.h>
    #include <qtextcodec.h>
    #include <qtranslator.h>
    
    #include "testopie.h"
    
    int main(int argc, char *argv[])
    {
    /** --------------------------------------- **/
    #ifdef QWS
      QPEApplication a(argc, argv);
    #else
      QApplication a(argc, argv);
    #endif
    //  QApplication a(argc, argv);
    //  a.setFont(QFont("helvetica", 12));  // Dont use font and scaling for embedded use
                                            // You never know, how large the display is.
    /** --------------------------------------- **/
      QTranslator tor( 0 );
      // set the location where your .qm files are in load() below as the last parameter instead of "."
      // for development, use "/" to use the english original as
      // .qm files are stored in the base project directory.
      tor.load( QString("testopie.") + QTextCodec::locale(), "." );
      a.installTranslator( &tor );
      /* uncomment the following line, if you want a Windows 95 look*/
      // a.setStyle(WindowsStyle);
    
      TestopieApp *testopie=new TestopieApp();
    /** --------------------------------------- **/
    #ifdef QWS_OPIE
      a.showMainWidget(testopie);
    #else
      a.setMainWidget(testopie);
    #endif
    //  a.setMainWidget(testopie);
    /** --------------------------------------- **/
    
      testopie->show();
    
      return a.exec();
    }
            
    

  13. Now we have to recompile again <F8>. It should build OK. If you now try to start the application using <F9>, you get the following result.


    That happens, because you did not yet start QVFB, the framebuffer emulator of trolltech (to get it working see here).
  14. call /usr/local/bin/qfvb &. This should start your qvfb application. You will see a 240x320 Window with a black background.


    If you start your testopie application with <ALT+F9> you are asked to enter parameters. Enter -qws to mark your embedded application as the master application (no other app is running yet) and press OK. The result is shown in the next figure.


Congratulations !!!
You finally made it ...

The result binary can be found in the directory $HOME/testopie/emb/testopie.

8.5 Prepare kdevelop for arm (cross) use

To go to real opie (ipaq / sharp) from here is easy. Stop kdevelop, exit your qtopieemb environment and switch to qtopiesharp environment instead. Restart kdevelop from the shell.

Note that we do the preparation for arm here, but call the kdevelop target opie, as the resulting ipks are usable for ipaq and sharp .

To prepare for arm crosscompiling, follow the steps below.

  1. Enter the menu project/options and choose compiler setup.
  2. Overwrite the Text (Standard) in the "Configuration" combo box with opie instead. Press the Add button right of that. This will enable the build-dir field. You can chage it or let as it is. Kdevelop chooses the dir ../opie to store the result. Choose arm as the architecture.
  3. Choose the tab page Flags and Warnings. Choose Wall as compiler warnings and enter $OPTIONS $EXTRA_INC_PATH into the CXXFLAGS field (They were wanted in CPPFLAGS in kdevelop versions before).
    Note, that kdevelop is able to decode environment variables (coming from your environment scripts) in this field.
  4. Choose the tab page Linker Flags. Enter $EXTRA_LIB_PATH Additional Flags field (environment variable).
  5. Choose the tab page Configure. Enter /usr/lib/qt2opie-ipaq into the --with-qt-dir field and --enable-embedded --enable-qtopia into the Additional Options field.
  6. Choose the menu entry linker-options. Enter $(LIB_QPE) $(KDEVXT_LIB) into the additional library field.
    Note, that it is immediately necessary to use an environment variable ($(KDEVXT_LIB)) here, as the linker tab page dont differt between the different targets. That was not possible with the kdevelop versions before 2.1.5.
  7. Pressing the OK-button will start the configure script and cause an error. Dont be frustrated, everything is OK so far (see the error message below).

  8. From the targets combobox (second ToolBar line, very left) you can choose, which target you want to compile. Choose standard first, and select from the menu build/distclean.
    Note, that you have to do that always, when you changed between two targets. If you gget an error message (makefile missing), you can go on with the next item.
  9. To get another target (here opie) compiled select opie from the combobox. Now you have to select from the menu build/autoconf and automake and afterwards build/configure (Confirm the configure-options as presented). Afterwards, you should have the program prepared for arm (opie) compilation.
  10. Compile your test program now for arm use. The following figure shows the result.


    Note, that kdevelop used arm-linux-g++ instead og g++.

Congratulations !!!
You finally made it ...

The result binary can be found in the directory $HOME/testopie/opie/testopie. Transfer the binary to your handheld and try it starting it from a shell. It should work out of the box. Here is the screenshot from my ipaq.


8.6 Use QT-Designer to extend your application

to be done ...

Create the main view

Add a new Dialog.

8.7 Automated ipkg creation

NOT ACTUAL - Will be subject of change

This section describes the tools I prepared to create automated ipkgs out of kdevelop arm(opie) project.

Some shell- and perlscripts copied into the project dir of your project and adopted to you needs will allow you to create an ipkg mostly automated. This is not helpfull (or only partly) for Opie integration, as opie creates its own ipk package. But the user may want to use his project as a standalone ipkg. In this case follown the instructions below. If you are behind Opie integration, you may want to use the automatic created *.desktop and *.pro file.

Again we use our above created testopie project as an example.

Unpack tha tar ball ipkg_kdev_x.y.z.tgz in $HOME/testopie. The result will be two additional files _postinst and _xtrarc and a subdir ipkg.

The following itemlist describes the different files and how to manipulate them.

Preparation

ipk_opie.pl is a helpfull script to automize the ipkbuild process and all related stuff using kdevelop. Grab the download file (see download section), unpack it and copy the resulted content of subdir ipkg_kdev into your project directory (cd ipkg_dev;cp -r * /where/your/project/is). The result are the scripts located into the ipkg dir and the two scripts _xtrarc and _postinst in your project dir. Edit that both files to your needs (Like descibde above).

Doit

To build the ipkg just cd to your project dir and enter the following line (assuming that the kdevelop arm build process is finished).

qtopiesharp;ipkg/ipk_opie.pl package opie testopie $PWD

This will create everything you need assuming, that package is the destination dir and opie the kdevelop build dir. The result can be found in $PWD/package.

The perl script of me also copies the result to my local ipk-dir, which at the moment is /home/sc/project/scipkgs. The path to there is actually defined in the script ipk_opie.pl ( variable is $ipk_destipk ). It also manipulates the Package file there to be able to install the ipk via ipkg install testopie on the handheld.

WhatIsdone

This section prints the perl scripts main calls to show how it works.

        getArgs();              # get the program arguments and check whether OK
        startPrepScript();      # starts prepipk.rc with appropriate parameters
        startCpScript();        # starts cpipk.rc with appropriate parameters
        grabPrjFile();          # grabs all necessary information from the project file
        setShortInfo();         # set the short info (desktop info)
        createControlFile();    # creates the ipk CONTROL file
        createPackageFile();    # creates the package file
        prepQpeApp();           # creates the QTopia desktop file
        startBuildScript();     # starts the ipk build strip buildipk.rc
        # startGpgScript();     # Start the GPG key generation (for familiar upload)
        copyToDest();           # copies the result into the local ipkgs dir
                                # and manipulates the Packages file.
        

8.8 Known bugs

This chapter describes the known bugs in relation to the crosscompiling feature. The version is kdevelop 2.1.5 (KDE 3.1)


Next Previous Contents