Qt Creator 4 custom plugin get current branch for project under version control

  • I have noticed when creating a qmake project, that if it is under version control the branch name shows up in the project node display text. I have searched for hours and I have been unsuccessful at locating where this happens within the source code. The reason I ask, is I have a custom project manager plugin that will contain multiple repositories and I would like to display the current branch in the folder node display text.

  • I figured out how to get the branch information. The code is below that I used to get the branch information given an absolute path.


    #include <coreplugin/vcsmanager.h>
    #include <coreplugin/iversioncontrol.h>


    bool ROSProjectNode::hasVersionControl(const QString &absolutePath, QString &vcsTopic) const
      if (Core::IVersionControl *vc = Core::VcsManager::findVersionControlForDirectory(absolutePath))
        if (absolutePath == Core::VcsManager::findTopLevelForDirectory(absolutePath))
          vcsTopic = vc->vcsTopic(absolutePath);
          return true;
      return false;

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.