Qt Quick Templates 2 documentation
Where can i find descriptions of QML types in QtQuick.Templates namespace? And when am i supposed to use this module?
You can/should use QtQuick Templates when you want/need empty and unstyled controls. This is the case when implementing styles for Qt Quick Controls, for instance. Outside the scope of styling, the same applies also to heavily customized application-specific controls. It is better to take an empty template than to customize an existing style by replacing all the default visuals it offers.
The API of QtQuick Controls is defined by QtQuick Templates. Given that the APIs of the two are identical, for the sake of simplicity, there is no separate documentation for QtQuick Templates. There are enough Button, Switch, and Slider types in the Qt docs, right? ;) While the ready-made QtQuick Controls are primarily targeted at application developers, the QtQuick Templates are suited for more advanced users building entire platforms or custom look'n'feels. Some of these users are even building their own SDK and thus, writing their own documentation.
So QtQuick templates are then basically internal types that expose C++ parts of QtQuick Controls to QML? Still if they have exactly same interface as the Controls types, i don't really understand when they are useful(to me as QtQuick user). It seems to me that one should always use Controls types, and in case of different styling to simply create new types derived from them. I understand you can do it with the empty Template as well, but why do more work than minimally required?
And if there are some performance gains in the latter option, worry about it seems to me to be a case of premature optimization, and how much would you gain anyway?
In the beginning, the templates were a hidden internal implementation detail, but when the re-engineered Qt Quick Controls were first time presented to a larger audience at the Qt World Summit in 2015, the immediate feedback was that having access to the templates would be immensely useful.
A concrete example from our consultant partners. The first generation controls were often too heavy, so they had been rolling their own custom controls over and over again in every customer project that required a custom style.
The templates do not only define the API, but also implement the logic and behavior. Just fill in the blanks, and you've got fully functional controls. While it's not rocket science to implement your own buttons from scratch, using the templates starts paying off as soon as you move on to anything more complex.
For you, as a Qt Quick user, if there's anything useful in the ready made styled controls, by all means, use them. However, if you end up customizing a control to a degree that it overrides everything a ready-made style provides, I strongly suggest using a template instead. Even though the default visuals do get cleaned up whilst replacing them with custom visuals, the way the QML engine works today is that we can't avoid evaluating that QML code in the default visuals. There were some preliminary attempts to change that, but given that it broke several tests across the code base, we wouldn't be able to make such a fundamental change before Qt 6, at least.