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.
- Start Visual Studio. Go to File->New->Project. Choose a name and location for the project. Press on ‘OK’.
- Choose the ‘QT4-based application’ template. Click on ‘Next’.
- 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.If 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.
- Press on ‘Next’ once the remote computer has been selected.
- 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.
- 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’.
- Build the newly created project.
- Set a breakpoint as shown below and start debugging.
- Choose a preexisting XMing installation location or let VisualGDB install it for you.
- The qt window is shown inside X Server. Press on the button.
- Our breakpoint is hit. We are succesfully debugging qt applications on Raspberry Pi through Visual Studio.
- 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.
- In the debug settings you can also change the display mode to keep graphics on the Raspberry Pi.
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).