C

TranslationFiles.MCU.fileSelector

A list of strings, specifies which variants to use when picking translation files.

Description

The fileSelector property is used when the project has multiple files with the same name and purpose, but its contents varies depending on the selected device characteristics screen size, platform, languages ...ext, and each file is intended for a specific set of characteristics.

It is used to keep the reference to the file the same across all variants.

In a qmlproject, this property can be set at different levels as listed bellow, qmlprojectexporter get the selectors value following the same order

  • In files nodes (QmlFiles, ImageFiles, FontFiles ModuleFiles and TranslationFiles) through the "MCU.fileSelector" property
  • in MCU.Config node using "fileSelector" property, this will apply to all the nodes in the file that does not have "MCU.fileSelector" defined.
  • Using qmlprojectexportor --selector argument, This is used to configure the whole project and the selectors will be applied to all qmlproject files used in the project (main file and the imported modules)
  • Lastly default QFileSelector selectors can also be used in the project.

Note: The possible selector values depend only on how the folders are named in the project (folders that start with "+" are considered to be a variant that can be selected)

Note: It is possible to chain selectors "project/+selector_one/+selector_two/resource.png"

Warning: the selectors should be placed at the end of the resource path any selector in the middle will not be used as a selector but as a normal folder, for example "project/+wrong_selector/normal_folder/+correct_selector1/+correct_selector2/resource.png"

Usage

// Project files:
// with different translation files for each screen
//      src/translations/+main_screen/home.ts
//      src/translations/+secondary_screen/home.ts

//Picks src/translations/+main_screen/home.ts
TranslationFiles {
    MCU.fileSelector: ["main_screen"]
    files: ["src/translations/home.ts"]
}

Since

This property was introduced in QmlProject API 1.3 .

Available under certain Qt licenses.
Find out more.