Skip navigation

Debugging MeeGo applications

Filter Guides

Released:  Mon, 2011-06-06

This guide introduces debugging Qt applications with MeeGo. You should have already installed the MeeGo SDK and configured Qt Creator for MeeGo development.



In Qt Creator you setup MeeGo device configurations to deploy your application to either a real hardware device or to a virtual machine, such as QEMU, running on your host. Qt Creator treats these configurations in the same way. When you start to debug your application Qt Creator will package your applications as an RPM, deploy it to the device you've selected in your project settings, install it, and run the executable.

Prepare the target device or emulator

Follow the instructions for the type of target you will use:

Configure your project for debugging

Ensure that debugging is enabled for the version of Qt in use:

  1. Click on the Projects button in the left-hand panel.
  2. Under General, click on the Manage button next to Qt Version.
  3. Select the Qt version you are using: use the MeeGo Qt version for your particular target (for example, meego-tablet-ia32-1.2.0.90.0.20110517.1 for an ExoPC or touch-enabled netbook).
  4. Click on the Rebuild button next to Debugging helpers (near the bottom of the dialog box). This builds the debugging helper for this version of Qt. You should see a green tick under the Debugging column for that Qt version.

Set a breakpoint

Open your source where you want to set a breakpoint and click to the left of the line number. A red circle appears indicating the point where the program will stop when running. Start debugging by clicking the "Start Debugging" icon (green triangle with a beetle on top) or from the top menu: Debug > Start Debugging

Sample project setup

If you don't already have your own program, here are some steps to get you started.

  1. Follow the instructions for creating a simple MeeGo application.
  2. Click on the "Edit" icon on the left of the IDE.
  3. Double-click the main form (mainwindow.ui). Qt Designer opens your form.
  4. Add a Push Button to the form by dragging and dropping one from the panel on the left into the window
  5. Add a click handler for the button using Qt's signal/slot mechanism as shown below (bold code):
    File: mainwindow.cpp
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include 
    
    namespace Ui {
        class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
    
    
    // our new button handler
    private slots:
        void onButtonClicked();
    
    };
    
    #endif // MAINWINDOW_H
    

    File: mainwindow.cpp

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QDebug> 
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        
        QObject::connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::onButtonClicked()
    {
       //don't forget the #include at the top of this file for QDebug
        QString message = "I have been well and truly clicked";
        qDebug() << message;
    }
    

    Most of this is boilerplate code generated when the project was created. The bold code was added to provide a handler when the button is clicked.

  6. Add a breakpoint next to the line where you want the debugger to break by clicking to the left of the line number.





    (Note the red circle on line 22.)
  7. Configure Qt to build the debug version of your project:
    1. In the left-hand panel, click on Projects.
    2. Under Build Settings, select Debug from the drop-down box next to Edit build configuration.
    3. From the Build menu, select Rebuild all. This recompiles the project using the debug-enabled Qt.

Debug the application

Start debugging by clicking the "Start Debugging" icon (green triangle with a beetle on top) or from the top menu: Debug > Start Debugging. The application will start on the remote device or emulator. In Qt Creator, some extra panels show the stack, watch expressions, and other useful debugging information.



Click on the button we added to the form. The program should pause at the breakpoint. Switch back to Qt Creator and look at the debug panels. The message variable is visible in the Locals and Watchers tab, set to "I have been well and truly clicked".






Click on the Continue button in the debugger. This sets the application running again, passing over the breakpoint. Note that the application (on the remote device) won't respond until you click this.

Next Steps

For more information about using Qt Creator in debug mode, see http://doc.qt.nokia.com/qtcreator-snapshot/creator-debugging.html.