How to Configure and Use the Qt Creator GitLab Integration

How to Configure and Use the Qt Creator-GitLab Integration

By Jeff Tranter

Starting with version 8.0.0 the Qt Creator IDE has a useful new plugin that allows you to browse and clone projects from a GitLab server. While easy to use, it is not well documented, so I thought I would write a blog post that describes how to configure and use it.

Requirements

You will need Qt Creator version 8.0.0 (or later). You can identify the version from the menu entry Help / About Qt Creator...

about box

You will also need the curl program, which is typically installed by default on most Linux, macOS, and Windows 10 and 11 systems.

Enable the Plugin

As of Qt Creator version 8.0.0 the plugin is considered experimental and not enabled by default. To enable it, select Help / About Plugins... and select the Load checkbox for the plugin Utilities / GitLab (experimental).

plugins dialog

Close the dialog and it will then prompt you to restart Qt Creator:

restart dialog

Getting an Access Token

You will need something called an "access token" from your gitlab server in order to allow third-party code like Qt Creator to access your gitlab account. You can do thia from the gitlab web interface by clicking on your username at the top right and selecting Preferences. Select Access Tokens at the left.

Generate a new access token by entering a suitable Token name (e.g. Qt Creator). Select an expiration date if desired, and check all of the boxes under Select scopes.

access token

Click on Create personal access token. The UI will give an access token string which you will need in the next step when you configure the Qt Creator gitlab plugin.

access token

Configure the Plugin

To configure the Qt Creator plugin, go to Edit / Preferences..., select Version Control from the left tab, then GitLab from the top tab. Click on Add... Fill in the values for your gitlab server, as below but using suitable values for the gitlab server you use. Paste in the access token you received from gitlab.

configure plugin

using plugin

If the value for curl is highlighted in red it means that it is either not installed or not present at the specified path. Confirm that you do have it installed on your system and enter the full path, if needed. Click OK to save the configuration settings. Note that you can have multiple gitlab server sources if you work with multiple servers.

Using the Plugin

To use the plugin, click Qt Creator, select Tools / Gitlab... and select the server from the Remote: combo box. Within a few seconds, a list of the gitlab projects found on the server should appear:

using plugin

You can use the Search text field and button to filter the names if desired (the list can be quite large).

using plugin

If you select a project you can click on the Clone... button and you will be prompted for the git clone parameters, pre-filled in. Clicking on Clone will clone the repository into the selected working directory.

clone

After successfully checking out the files it will prompt you to select a CMake or qmake project file to open in Qt Creator.

select project

Conclusions

The gitlab plugin is quite simple but streamlines the often tedious process of finding the correct git URL to clone, checking it out, and opening the project in Qt Creator. Note that once you have a project open you can use the Tools / Git menu to perform other functions related to git.

If you're interested in other topics related to Qt, read more here.