| CMakeLists.txt |
|
1023 |
- |
| Gauge.qml |
|
7729 |
- |
| Main.qml |
|
351 |
- |
| minortickmarkcontainer.cpp |
|
3113 |
- |
| minortickmarkcontainer.h |
|
1277 |
- |
| tickmarkcontainer.cpp |
This class (and its subclass) creates and position the tickmarks/labels.
We do this in C++ for the reasons explained below.
Firstly, we need the labels to start at the bottom (for a
vertically-oriented gauge). Positioners like Column and Flow cannot do
this. Instead, we could use a Repeater:
// Note that we can't just use the count as the model, because that would then require
// require the delegate to handle this logic, which we don't want because
// delegates should only be responsible for styling.
model: [...Array(control.tickmarkCount).keys()].map(value => control.tickmarkCount - 1 - value)
However, we also need to vertically center each label on its corresponding
tickmark. That requires access to each delegate in order to position them,
which we can only do from C++. In Qt Quick Extras, this used to be avoided
by using Loader (code taken from Base/GaugeStyle.qml):
y: index * labelDistance - height / 2
The problem with this is that using a loader for every tickmark and label
is expensive.
Another option would be to require the delegate to do the positioning, but
that's not what we want.
|
9424 |
- |
| tickmarkcontainer.h |
|
2738 |
- |
| tickmarklabelcontainer.cpp |
|
3732 |
- |
| tickmarklabelcontainer.h |
|
1186 |
- |
| tst_how-to-cpp-gauge.cpp |
|
8941 |
- |
| valuerange.cpp |
!
\property ValueRange::minimumValue
\brief the minimum value that \l value can assume
The default value is \c 0.
|
4356 |
- |
| valuerange.h |
|
2340 |
- |