A simple regex-based project hierarchy parser/display


projectview implements project parser that is controlled by simple regular expression rules. This allows you to build a dynamic hierarchy of your software project for whatever language or application you desire, and provides a colorful, themeable tree widget for displaying it.


  • Language-independent
  • Detects circular dependencies and files not found
  • Totally themeable
  • Searchable with the built-in search box
  • Integrates with your editor


Here, projectview is showing a Spin language project.

projectview notifies the user when there is a circular dependency in inclusion.

It will also tell you when a file was not found.

projectview can be searched.



Parser parser;

Setting up search paths

To use projectview, you need to provide a filename and additional search paths for locating local dependencies.

parser.setLibraryPaths(QStringList() << "../../../");


To use projectview, you must build a description of the language elements you’d like to to display. This is done using the Parser::Rule structure,

A special Rule is defined for declaring file dependencies: _includes_. Using this variable will result in projectview looking in the file system for the string you extract from the source file.

Each rule can hold multiple patterns for languages that support multiple variations of a syntax with the same meaning.

Adding patterns

Rules are created by passing a list of patterns to the addRule function, so let’s create a list of patterns.

QList<Parser::Pattern> patterns;

Then, we create a Pattern.

Parser::Pattern pattern;

Each Pattern contains a regular expression and a list of values that describe how to extract the string.

To extract any data at all, your regular expression must contain unnamed pattern groups to extract.

pattern.regex = "^[ \t]*([a-zA-Z_]+[a-zA-Z0-9_]*)[ \t]*=[ \t]*(.+?)('.*?)?[ \t]*$";

capture is a QList<QVariant object that can hold either int or QString. If an int, it will capture a group from the regular expression. If a QString, the string will be added to the result.

pattern.capture << 1 << " returns " << 2;

Now add the pattern to the list.


Adding the rule

Provide a name, icon, and color for display.


Displaying the tree


Now use the getModel() function to display your project with a QTreeView.

QTreeView *tree= new QTreeView();