1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
int tickOffset = slider->style()->pixelMetric(QStyle::PM_SliderTickmarkOffset);
int thickness = slider->style()->pixelMetric(QStyle::PM_SliderControlThickness);
int len = slider->style()->pixelMetric(QStyle::PM_SliderLength);
int available = slider->style()->pixelMetric(QStyle::PM_SliderSpaceAvailable);
int interval = slider->tickInterval();
if (interval <= 0) {
interval = slider->singleStep();
if (QStyle::sliderPositionFromValue(slider->minimum(), slider->maximum(), interval, available)
- QStyle::sliderPositionFromValue(slider->minimum(), slider->maximum(), 0, available) < 3)
interval = slider->pageStep();
}
if (!interval)
interval = 1;
int fudge = len / 2;
int pos;
int bothOffset = 1;
int v = slider->minimum();
int i=0;
while (v <= slider->maximum() + 1) {
if (v == slider->maximum() + 1 && interval == 1)
break;
const int v_ = qMin(v, slider->maximum());
int tickLength = (v_ == slider->minimum() || v_ >= slider->maximum()) ? 4 : 3;
pos = QStyle::sliderPositionFromValue(slider->minimum(), slider->maximum(),
v_, slider->width()) + fudge;
QGraphicsLineItem line(QLineF(QPointF(pos, (i%2==0 ? 2 : 5)),
QPointF(pos +
QStyle::sliderPositionFromValue(slider->minimum(), slider->maximum(), thickness, slider->maximum()),
(i%2==0 ? 2 : 5))));
line.paint(&painter, &option);
i++;
// in the case where maximum is max int
int nextInterval = v + interval;
qWarning() << "nextInterval = " << nextInterval;
if (nextInterval < v)
break;
v = nextInterval;
} |
Partager