Creating Qt5 projects for Beaglebone-Debian with Visual Studio

This tutorial shows how to cross-compile a simple Qt5 application for the Beaglebone Black board running Debian using Visual Studio and VisualGDB.

Before you begin, either cross-compile the Qt framework for your board by following this tutorial, or download our toolchain with a pre-built Qt and install it to C:\SysGCC\Beaglebone.

Note that as Qmake hardcodes the absolute paths to various files, unless you build cross-Qt yourself, you would need to use the exact path that was used when building CMake. You will also need to upload the Qt binary files from the toolchain to your Beaglebone using SmarTTY or any other SSH client:upload

  1. Start Visual Studio and open VisualGDB Linux project Wizard:01-prjname
  2. On the first page select “Create a new project -> Application -> Use Qt”:02-qt
  3. Then select “Build the project locally”, choose your Beaglebone cross-toolchain and specify the connection settings for your Beaglebone. Then click “Configure Qt Settings”:03-qtconfig
  4. Select “Use previously configured Qt tools” and point VisualGDB to the qmake binary (<toolchain>\arm-linux-gnueabihf\sysroot\usr\local\qt5\bin\qmake.exe) and the mkspecs directory (<toolchain>\arm-linux-gnueabihf\sysroot\usr\local\qt5\mkspecs\devices\linux-beagleboard-g++):04-configqt
  5. Press “Finish” to generate the project. VisualGDB will ask whether to fix values for the environment variables that are different for interactive and command modes. Select “Fix value” and press OK:05-fixdirs
  6. Build your project by pressing Ctrl-Shift-B:06-build
  7. If IntelliSense fails to recognize the ui_MainWindow.h file, this happens because the directory containing it was not present when the project was created:07-senseRe-open the project and IntelliSense will start working.
  8. You can now press F5 to begin debugging. Qt will complain about the missing QT_XKB_CONFIG_ROOT and the keyboard won’t work for Qt applications:08-xkb
  9. To fix this, open VisualGDB Project Properties and set the QT_XKB_CONFIG_ROOT environment variable to /usr/share/X11/xkb:09-env
  10. Now the keyboard should work. Set a breakpoint in ButtonClicked() and click the button in the Qt window (or press the space key):10-wnd
  11. The breakpoint will be triggered:  10-msgbox
  12. Press F10 to step, or F5 to continue debugging. Once the msgBox.exec() gets called, you will see the Qt message box:11-hello
  13. You can also configure VisualGDB to show the remote Qt windows on the Beaglebone display directly:12-remoteFor this option to work, the same user that is used for SSH connection needs to be logged on to the Beaglebone.