Dec 21, 2021
A how-to guide with code samples on configuring and building your own custom QGroundControl application. We’ll be changing the UI based on a passcode that we supply to unlock different levels of access.
Environment Set-Up
If you already have the required software installed, double-check that you have the correct versions. Then you may continue to the section titled ‘Configuring the Project.’
Required Software
Microsoft Visual Studio 2019
Qt/Qt Creator
Installing Visual Studio 2019
Follow this link to download the last version of Visual Studio 2019:
Once downloaded, run the installer and check the box labeled, “Desktop development with C++”
Finish installing by checking the Install box
Installing Qt Creator
Follow this link, scroll down to the section titled “Looking for Qt binaries?”
Click the button labeled “Download the Qt Online Installer”
A page will show up with a green button labeled “Download”. Click it and the QT Online Installer will download
After downloading, launch the installer
Log in / Create an account for Qt
Check the box claiming you are an individual
Hit next until you reach installation folder
Check the box labeled “Custom Installation” and hit next
Select the dropdown for Qt and check the box labeled “5.15.2”
Finish installation by hitting next until it is complete
Configuring the Project
Clone the QGroundControl repository found here:
Open Qt Creator
Select “File” and then “Open File or Project...”
Navigate to the repository
Select the file “qgroundcontrol.pro”
Select “Configure Project”
In the terminal window navigate to the [QGroundControl Repository]/custom
Update sub dependencies with this command:
git submodule update --recursive
Restart Qt Creator
The project will now be able to build without any modifications
Building & Deployment
In Qt Creator, select the hammer button in the bottom right corner to build the project
Select the green run button to run the project. The default configuration will be on desktop
It will create a folder outside of the project folder (default is [user]/Documents) containing the flight logs, missions, and other miscellaneous items
It will also create a build folder next to the project folder containing an executable as well as staging files
Development
Any files that are mentioned from “the Github Repository” can be found here: https://github.com/riis/qgccomponenthiding
Adding the Access Type cc/h files
Create 4 new files under custom/src:
AccessTypeConfig.cpp
AccessType.h
For AccessType.cpp, copy “AccessType.cpp”from the Github Repository
For AccessTypeConfig.cpp, copy “AccessTypeConfig.cpp”from the Github Repository
For AccessType.h, copy “AccessType.h”from the Github Repository
For AccessTypeConfig.h, copy “AccessTypeConfig.h”from the Github Repository
Adding the Custom Plugins
The custom plugins allow the user to have access types depending on the drone firmware. In this case, the firmware that will have a custom plugin is PX4-based
Create 6 new files under custom/src (All these files - CustomCorePlugin are modified versions of their original counterparts found under src/FirmwarePlugin/PX4):
CustomFirmwarePluginFactory.h
CustomPX4FirmwarePlugin.h
CustomCorePlugin.h
CustomFirmwarePluginFactory.cc
CustomPX4FirmwarePlugin.cc
CustomCorePlugin.cc
In CustomFirmwarePluginFactory.h, copy “CustomFirmwarePluginFactory.h”from the Github Repository
In CustomCorePlugin.h, copy “CustomCorePlugin.h”from the Github Repository
In CustomFirmwarePluginFactory.cc, copy “CustomFirmwarePluginFactory.cc”from the Github Repository
In CustomPX4FirmwarePlugin.h, copy “CustomPX4FirmwarePlugin.h”from the Github Repository
In CustomCorePlugin.cc, copy “CustomCorePlugin.cc”from the Github Repository
In CustomPX4FirmwarePlugin.cc, copy “CustomPX4FirmwarePlugin.cc”from the Github Repository
Passcode Manager
This is how the logic is handled for setting and changing the user’s access types
Create 2 new files under custom/src/PasscodeMenu:
PascodeManager.h
PasscodeManager.cc
In PasscodeManager.h, copy “PascodeManager.h”from the Github Repository
In PasscodeManager.cc, copy “PasscodeManager.cc”from the Github Repository
Configuring the custom.pri file
This is the project initialization file
Open the custom.pri file
Under SOURCES, add the following:
$$PWD/src/AccessType.cpp \
$$PWD/src/AccessTypeConfig.cpp \
$$PWD/src/CustomFirmwarePluginFactory.cc \
$$PWD/src/CustomPX4FirmwarePlugin.cc \
$$PWD/src/CustomCorePlugin.cc \
$$PWD/src/PasscodeMenu/PasscodeManager.cc
3. Under HEADERS, add the following:
$$PWD/src/AccessType.h \
$$PWD/src/AccessTypeConfig.h \
$$PWD/src/CustomFirmwarePluginFactory.h \
$$PWD/src/CustomPX4FirmwarePlugin.h \
$$PWD/src/CustomCorePlugin.h \
$$PWD/src/PasscodeMenu/PasscodeManager.h
Overriding the Custom Motor Component QML
This will override the original Motor Component
Under custom/res/Custom, create the file CustomMotorComponent.qml and copy “CustomMotorComponent.qml”from the Github Repository
In custom/qgroundcontrol.exclusion, add this line:
<file alias="MotorComponent.qml">../src/AutoPilotPlugins/Common/MotorComponent.qml</file>
In custom/custom.qrc, under the section with the prefix “qml”, add this line:
<file>CustomMotorComponent.qml</file>
In the terminal window navigate to the [QGroundControl Repository]/custom and run this command:
python updateqrc.py
Passcode Menu QML
Under custom/res, create the file, PasswordSettings.qml, and copy “14”from the Github Repository
In custom/custom.qrc, under the section with the prefix “qml”, add this line:
<file alias="PasswordSettings.qml">res/PasswordSettings.qml</file>