Skip to content

Commit 8ff7a38

Browse files
committedJan 10, 2017
add 'qgis_short_version' expression variable to retrieve QGIS version
in the major.minor notation (can be useful for help system and probably in other places)
1 parent a074343 commit 8ff7a38

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed
 

‎src/core/qgsexpressioncontext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ QgsExpressionContextScope* QgsExpressionContextUtils::globalScope()
521521
//add some extra global variables
522522
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "qgis_version" ), Qgis::QGIS_VERSION, true ) );
523523
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "qgis_version_no" ), Qgis::QGIS_VERSION_INT, true ) );
524+
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "qgis_short_version" ), QStringLiteral( "%1.%2" ).arg( Qgis::QGIS_VERSION_INT / 10000 ).arg( Qgis::QGIS_VERSION_INT / 100 % 100 ), true ) );
524525
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "qgis_release_name" ), Qgis::QGIS_RELEASE_NAME, true ) );
525526
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "qgis_platform" ), QgsApplication::platform(), true ) );
526527
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "qgis_os_name" ), QgsApplication::osName(), true ) );

0 commit comments

Comments
 (0)
Please sign in to comment.