Frameworks-QtSupport

Configuration support for projects using Qt

Required inputs: IR

This rule simplifies the configuration of projects using Qt. It suppresses issues resulting from the required used of Qt macros like Q_OBJECT and it evaluates calls to Qt's connect() function to determine call relations for the connection between signals and slots.

Also it adds filename patterns

  • */mocs_compilation*.cpp
  • */moc_*.cpp
  • *.moc
  • */qrc_*.cpp
  • */ui_*.h
  • */qmlcache/*
  • mocs_compilation*.cpp
  • moc_*.cpp
  • qrc_*.cpp
  • ui_*.h
  • qmlcache/*
to C++CloneDetection/pre_excludes and optionally to the global excludes for files generated by Qt.

For Qt-specific rules, there exists the rulegroup Qt.

Possible Messages

This rule has no predefined messages.

Options

The following places define options that affect this rule: Analysis-GlobalOptions

create_qt_connect_edges

create_qt_connect_edges : bool = True

If true (default), create Qt_MetaObject_Call edges between signals and slots that are connected with detectable connect() calls. Qt_Connect_Signal and Qt_Connect_Slot edges are created between routines containing connect() calls and the referenced signals and slots respectively. All these edges are created and inserted into the views Code Facts and Declaration Facts.
 

exclude_qt_generated_files

exclude_qt_generated_files : bool = True

If true, filename patterns for files generated by Qt will be implicitly added to the global excludes. The patterns can be configured via qt_exclude_patterns and the defaults are:
  • */mocs_compilation*.cpp
  • */moc_*.cpp
  • *.moc
  • */qrc_*.cpp
  • */ui_*.h
  • */qmlcache/*
  • mocs_compilation*.cpp
  • moc_*.cpp
  • qrc_*.cpp
  • ui_*.h
  • qmlcache/*
In addition, also everything beneath qtdir (if configured) is excluded.
 

qt_exclude_in_macros

qt_exclude_in_macros : set[str] = {'Q_DECLARE_*', 'Q_DISABLE_COPY', 'Q_ENUM', 'Q_GADGET', 'Q_GLOBAL_STATIC', 'Q_OBJECT'}

Macro name patterns for Qt-internal macros where no rule should be applied.
 

qt_exclude_patterns

qt_exclude_patterns

Type: set[bauhaus.analysis.config.FileGlobPattern]

Default: {'*.moc', '*/moc_*.cpp', '*/mocs_compilation*.cpp', '*/qmlcache/*', '*/qrc_*.cpp', '*/ui_*.h', 'moc_*.cpp', 'mocs_compilation*.cpp', 'qmlcache/*', 'qrc_*.cpp', 'ui_*.h'}

Filename patterns for files generated by Qt.
 

qt_types

qt_types : set[bauhaus.analysis.config.QualifiedName] = {'QObject'}

Set of qualified type names to be ignored or considered by other rules. Currently, only the rule AutosarC++-A18.5.2 uses this value for its option allow_for_types_and_subtypes if unset. For this Autosar rule also the option qtdir and exclude_qt_generated_files should be set to avoid violations within the Qt library.
 

qtdir

qtdir : bauhaus.analysis.config.LayerRelativePath | None = None

Installation directory of Qt. If provided, this is used to determine several additional entry points (Qt public methods, redefinitions of public Qt virtual methods as commonly used in, for example, user-defined plugins, undefined senders from the Qt directory).