Developing Qt applications for Raspberry Pi

This tutorial shows how to develop Qt applications for Raspberry Pi in Visual Studio.

Before we begin, ensure that VisualGDB 3.0 or later is installed.

  1. Start Visual Studio. Go to File->New->Project. Choose a name and location for the project. Press on ‘OK’.01-newproject
  2. Choose the ‘QT4-based application’ template. Click on ‘Next’.02-choosetemplate
  3. Choose the Raspberry Pi as the remote computer. If you do not have a previous Raspberry Pi SSH connection, then make new one. Fill in the connection details and press on ‘Create’. Note that the user name is “pi” by default and the password is “raspberry“. It is recommended to check the ‘Setup public key authentication’ option.07-newsshconnectionIf you don’t enable public key authentication, VisualGDB will remember your password for this connection. The stored passwords are encrypted using a key stored in your Windows account. Thus, the password will only be available once you login using your Windows account.
  4. Press on ‘Next’ once the remote computer has been selected.09-hostselection
  5. The Raspberry PI will be tested for the qt4-qmake package. If it is not installed, you can install it directly from VisualGDB. Use the sudo command to install the package.10-packages11-rootaccess12-installpackages
  6. On the source location page choose how the project sources are to be handled. Shared directories are recommended for large projects, but for simplicity we choose choose transferring here. Press on ‘Finish’.13-transfersources
  7. Build the newly created project.14-build
  8. Set a breakpoint as shown below and start debugging.15-setbreakpoint
  9. Choose a preexisting XMing installation location or let VisualGDB install it for you.15-xming
  10. The qt window is shown inside X Server. Press on the button. 17-qtscreenshot
  11. Our breakpoint is hit. We are succesfully debugging qt applications on Raspberry Pi through Visual Studio. 18-breakpointhit
  12. Stop debugging. Right-click on the project in Solution Explorer, choose VisualGDB Project Properties. In the properties window you can change many of the settings chosen in the wizard and more. Since VisualGDB version 4.0 it is possible to edit the Qt pro files directly from the VisualGDB Project Properties.19-projectproperties
  13. In the debug settings you can also change the display mode to keep graphics on the Raspberry Pi.20-changechanneling

Building QT projects on Raspberry PI can be slow. If you want a faster option follow the QT Cross-Compilation tutorial (requires VisualGDB 4.1 or later).