Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qabstractslider.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
<
qapplication
.
h
>
6
#
include
"qabstractslider.h"
7
#
include
"qevent.h"
8
#
include
"qabstractslider_p.h"
9
#
include
"qdebug.h"
10
#
if
QT_CONFIG
(
accessibility
)
11
#
include
"qaccessible.h"
12
#
endif
13
#
include
<
limits
.
h
>
14
15
#
include
<
private
/
qapplication_p
.
h
>
16
17
QT_BEGIN_NAMESPACE
18
19
/*!
20
\class QAbstractSlider
21
\brief The QAbstractSlider class provides an integer value within a range.
22
23
\ingroup abstractwidgets
24
\inmodule QtWidgets
25
26
The class is designed as a common super class for widgets like
27
QScrollBar, QSlider and QDial.
28
29
Here are the main properties of the class:
30
31
\list 1
32
33
\li \l value: The bounded integer that QAbstractSlider maintains.
34
35
\li \l minimum: The lowest possible value.
36
37
\li \l maximum: The highest possible value.
38
39
\li \l singleStep: The smaller of two natural steps that an
40
abstract sliders provides and typically corresponds to the user
41
pressing an arrow key.
42
43
\li \l pageStep: The larger of two natural steps that an abstract
44
slider provides and typically corresponds to the user pressing
45
PageUp or PageDown.
46
47
\li \l tracking: Whether slider tracking is enabled.
48
49
\li \l sliderPosition: The current position of the slider. If \l
50
tracking is enabled (the default), this is identical to \l value.
51
52
\endlist
53
54
Unity (1) may be viewed as a third step size. setValue() lets you
55
set the current value to any integer in the allowed range, not
56
just minimum() + \e n * singleStep() for integer values of \e n.
57
Some widgets may allow the user to set any value at all; others
58
may just provide multiples of singleStep() or pageStep().
59
60
QAbstractSlider emits a comprehensive set of signals:
61
62
\table
63
\header \li Signal \li Emitted when
64
\row \li \l valueChanged()
65
\li the value has changed. The \l tracking
66
determines whether this signal is emitted during user
67
interaction.
68
\row \li \l sliderPressed()
69
\li the user starts to drag the slider.
70
\row \li \l sliderMoved()
71
\li the user drags the slider.
72
\row \li \l sliderReleased()
73
\li the user releases the slider.
74
\row \li \l actionTriggered()
75
\li a slider action was triggered.
76
\row \li \l rangeChanged()
77
\li a the range has changed.
78
\endtable
79
80
QAbstractSlider provides a virtual sliderChange() function that is
81
well suited for updating the on-screen representation of
82
sliders. By calling triggerAction(), subclasses trigger slider
83
actions. Two helper functions QStyle::sliderPositionFromValue() and
84
QStyle::sliderValueFromPosition() help subclasses and styles to map
85
screen coordinates to logical range values.
86
87
\sa QAbstractSpinBox, QSlider, QDial, QScrollBar, {Sliders Example}
88
*/
89
90
/*!
91
\enum QAbstractSlider::SliderAction
92
93
\value SliderNoAction
94
\value SliderSingleStepAdd
95
\value SliderSingleStepSub
96
\value SliderPageStepAdd
97
\value SliderPageStepSub
98
\value SliderToMinimum
99
\value SliderToMaximum
100
\value SliderMove
101
102
*/
103
104
/*!
105
\fn void QAbstractSlider::valueChanged(int value)
106
107
This signal is emitted when the slider value has changed, with the
108
new slider \a value as argument.
109
*/
110
111
/*!
112
\fn void QAbstractSlider::sliderPressed()
113
114
This signal is emitted when the user presses the slider with the
115
mouse, or programmatically when setSliderDown(true) is called.
116
117
\sa sliderReleased(), sliderMoved(), isSliderDown()
118
*/
119
120
/*!
121
\fn void QAbstractSlider::sliderMoved(int value)
122
123
This signal is emitted when sliderDown is true and the slider moves. This
124
usually happens when the user is dragging the slider. The \a value
125
is the new slider position.
126
127
This signal is emitted even when tracking is turned off.
128
129
\sa setTracking(), valueChanged(), isSliderDown(),
130
sliderPressed(), sliderReleased()
131
*/
132
133
/*!
134
\fn void QAbstractSlider::sliderReleased()
135
136
This signal is emitted when the user releases the slider with the
137
mouse, or programmatically when setSliderDown(false) is called.
138
139
\sa sliderPressed(), sliderMoved(), sliderDown
140
*/
141
142
/*!
143
\fn void QAbstractSlider::rangeChanged(int min, int max)
144
145
This signal is emitted when the slider range has changed, with \a
146
min being the new minimum, and \a max being the new maximum.
147
148
\sa minimum, maximum
149
*/
150
151
/*!
152
\fn void QAbstractSlider::actionTriggered(int action)
153
154
This signal is emitted when the slider action \a action is
155
triggered. Actions are \l SliderSingleStepAdd, \l
156
SliderSingleStepSub, \l SliderPageStepAdd, \l SliderPageStepSub,
157
\l SliderToMinimum, \l SliderToMaximum, and \l SliderMove.
158
159
When the signal is emitted, the \l sliderPosition has been
160
adjusted according to the action, but the \l value has not yet
161
been propagated (meaning the valueChanged() signal was not yet
162
emitted), and the visual display has not been updated. In slots
163
connected to this signal you can thus safely adjust any action by
164
calling setSliderPosition() yourself, based on both the action and
165
the slider's value.
166
167
\sa triggerAction()
168
*/
169
170
/*!
171
\enum QAbstractSlider::SliderChange
172
173
\value SliderRangeChange
174
\value SliderOrientationChange
175
\value SliderStepsChange
176
\value SliderValueChange
177
*/
178
179
QAbstractSliderPrivate::QAbstractSliderPrivate()
180
: minimum(0), maximum(99), pageStep(10), value(0), position(0), pressValue(-1),
181
singleStep(1), singleStepFromItemView(-1), viewMayChangeSingleStep(
true
), offset_accumulated(0), tracking(
true
),
182
blocktracking(
false
), pressed(
false
),
183
invertedAppearance(
false
), invertedControls(
false
),
184
orientation(Qt::Horizontal), repeatAction(QAbstractSlider::SliderNoAction)
185
{
186
}
187
188
QAbstractSliderPrivate::~QAbstractSliderPrivate()
189
{
190
}
191
192
/*!
193
Sets the slider's minimum to \a min and its maximum to \a max.
194
195
If \a max is smaller than \a min, \a min becomes the only legal
196
value.
197
198
\sa minimum, maximum
199
*/
200
void
QAbstractSlider::setRange(
int
min,
int
max)
201
{
202
Q_D(QAbstractSlider);
203
int
oldMin = d->minimum;
204
int
oldMax = d->maximum;
205
d->minimum = min;
206
d->maximum = qMax(min, max);
207
if
(oldMin != d->minimum || oldMax != d->maximum) {
208
sliderChange(SliderRangeChange);
209
emit rangeChanged(d->minimum, d->maximum);
210
setValue(d->value);
// re-bound
211
}
212
}
213
214
215
void
QAbstractSliderPrivate::setSteps(
int
single,
int
page)
216
{
217
Q_Q(QAbstractSlider);
218
singleStep = qAbs(single);
219
pageStep = qAbs(page);
220
q->sliderChange(QAbstractSlider::SliderStepsChange);
221
}
222
223
/*!
224
Constructs an abstract slider.
225
226
The \a parent argument is sent to the QWidget constructor.
227
228
The \l minimum defaults to 0, the \l maximum to 99, with a \l
229
singleStep size of 1 and a \l pageStep size of 10, and an initial
230
\l value of 0.
231
*/
232
QAbstractSlider::QAbstractSlider(QWidget *parent)
233
:QWidget(*
new
QAbstractSliderPrivate, parent, { })
234
{
235
}
236
237
/*! \internal */
238
QAbstractSlider::QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent)
239
:QWidget(dd, parent, { })
240
{
241
}
242
243
/*!
244
Destroys the slider.
245
*/
246
QAbstractSlider::~QAbstractSlider()
247
{
248
}
249
250
/*!
251
\property QAbstractSlider::orientation
252
\brief the orientation of the slider
253
254
The orientation must be \l Qt::Vertical (the default) or \l
255
Qt::Horizontal.
256
*/
257
void
QAbstractSlider::setOrientation(Qt::Orientation orientation)
258
{
259
Q_D(QAbstractSlider);
260
if
(d->orientation == orientation)
261
return
;
262
263
d->orientation = orientation;
264
if
(!testAttribute(Qt::WA_WState_OwnSizePolicy)) {
265
setSizePolicy(sizePolicy().transposed());
266
setAttribute(Qt::WA_WState_OwnSizePolicy,
false
);
267
}
268
sliderChange(SliderOrientationChange);
269
updateGeometry();
270
}
271
272
Qt::Orientation QAbstractSlider::orientation()
const
273
{
274
Q_D(
const
QAbstractSlider);
275
return
d->orientation;
276
}
277
278
279
/*!
280
\property QAbstractSlider::minimum
281
\brief the sliders's minimum value
282
283
When setting this property, the \l maximum is adjusted if
284
necessary to ensure that the range remains valid. Also the
285
slider's current value is adjusted to be within the new range.
286
287
*/
288
289
void
QAbstractSlider::setMinimum(
int
min)
290
{
291
Q_D(QAbstractSlider);
292
setRange(min, qMax(d->maximum, min));
293
}
294
295
int
QAbstractSlider::minimum()
const
296
{
297
Q_D(
const
QAbstractSlider);
298
return
d->minimum;
299
}
300
301
302
/*!
303
\property QAbstractSlider::maximum
304
\brief the slider's maximum value
305
306
When setting this property, the \l minimum is adjusted if
307
necessary to ensure that the range remains valid. Also the
308
slider's current value is adjusted to be within the new range.
309
310
311
*/
312
313
void
QAbstractSlider::setMaximum(
int
max)
314
{
315
Q_D(QAbstractSlider);
316
setRange(qMin(d->minimum, max), max);
317
}
318
319
int
QAbstractSlider::maximum()
const
320
{
321
Q_D(
const
QAbstractSlider);
322
return
d->maximum;
323
}
324
325
326
327
/*!
328
\property QAbstractSlider::singleStep
329
\brief the single step.
330
331
The smaller of two natural steps that an
332
abstract sliders provides and typically corresponds to the user
333
pressing an arrow key.
334
335
If the property is modified during an auto repeating key event, behavior
336
is undefined.
337
338
\sa pageStep
339
*/
340
341
void
QAbstractSlider::setSingleStep(
int
step)
342
{
343
Q_D(QAbstractSlider);
344
345
d->viewMayChangeSingleStep = (step < 0);
346
if
(step < 0 && d->singleStepFromItemView > 0)
347
step = d->singleStepFromItemView;
348
349
if
(step != d->singleStep)
350
d->setSteps(step, d->pageStep);
351
}
352
353
int
QAbstractSlider::singleStep()
const
354
{
355
Q_D(
const
QAbstractSlider);
356
return
d->singleStep;
357
}
358
359
360
/*!
361
\property QAbstractSlider::pageStep
362
\brief the page step.
363
364
The larger of two natural steps that an abstract slider provides
365
and typically corresponds to the user pressing PageUp or PageDown.
366
367
\sa singleStep
368
*/
369
370
void
QAbstractSlider::setPageStep(
int
step)
371
{
372
Q_D(QAbstractSlider);
373
if
(step != d->pageStep)
374
d->setSteps(d->singleStep, step);
375
}
376
377
int
QAbstractSlider::pageStep()
const
378
{
379
Q_D(
const
QAbstractSlider);
380
return
d->pageStep;
381
}
382
383
/*!
384
\property QAbstractSlider::tracking
385
\brief whether slider tracking is enabled
386
387
If tracking is enabled (the default), the slider emits the
388
valueChanged() signal while the slider is being dragged. If
389
tracking is disabled, the slider emits the valueChanged() signal
390
only when the user releases the slider.
391
392
\sa sliderDown
393
*/
394
void
QAbstractSlider::setTracking(
bool
enable)
395
{
396
Q_D(QAbstractSlider);
397
d->tracking = enable;
398
}
399
400
bool
QAbstractSlider::hasTracking()
const
401
{
402
Q_D(
const
QAbstractSlider);
403
return
d->tracking;
404
}
405
406
407
/*!
408
\property QAbstractSlider::sliderDown
409
\brief whether the slider is pressed down.
410
411
The property is set by subclasses in order to let the abstract
412
slider know whether or not \l tracking has any effect.
413
414
Changing the slider down property emits the sliderPressed() and
415
sliderReleased() signals.
416
417
*/
418
void
QAbstractSlider::setSliderDown(
bool
down)
419
{
420
Q_D(QAbstractSlider);
421
bool
doEmit = d->pressed != down;
422
423
d->pressed = down;
424
425
if
(doEmit) {
426
if
(down)
427
emit sliderPressed();
428
else
429
emit sliderReleased();
430
}
431
432
if
(!down && d->position != d->value)
433
triggerAction(SliderMove);
434
}
435
436
bool
QAbstractSlider::isSliderDown()
const
437
{
438
Q_D(
const
QAbstractSlider);
439
return
d->pressed;
440
}
441
442
443
/*!
444
\property QAbstractSlider::sliderPosition
445
\brief the current slider position
446
447
If \l tracking is enabled (the default), this is identical to \l value.
448
*/
449
void
QAbstractSlider::setSliderPosition(
int
position)
450
{
451
Q_D(QAbstractSlider);
452
position = d->bound(position);
453
if
(position == d->position)
454
return
;
455
d->position = position;
456
if
(!d->tracking)
457
update();
458
if
(d->pressed)
459
emit sliderMoved(position);
460
if
(d->tracking && !d->blocktracking)
461
triggerAction(SliderMove);
462
}
463
464
int
QAbstractSlider::sliderPosition()
const
465
{
466
Q_D(
const
QAbstractSlider);
467
return
d->position;
468
}
469
470
471
/*!
472
\property QAbstractSlider::value
473
\brief the slider's current value
474
475
The slider forces the value to be within the legal range: \l
476
minimum <= \c value <= \l maximum.
477
478
Changing the value also changes the \l sliderPosition.
479
*/
480
481
482
int
QAbstractSlider::value()
const
483
{
484
Q_D(
const
QAbstractSlider);
485
return
d->value;
486
}
487
488
void
QAbstractSlider::setValue(
int
value)
489
{
490
Q_D(QAbstractSlider);
491
value = d->bound(value);
492
if
(d->value == value && d->position == value)
493
return
;
494
495
// delay signal emission until sliderChanged() has been called
496
const
bool
emitValueChanged = (value != d->value);
497
d->value = value;
498
499
if
(d->position != value) {
500
d->position = value;
501
if
(d->pressed)
502
emit sliderMoved(d->position);
503
}
504
#
if
QT_CONFIG
(
accessibility
)
505
QAccessibleValueChangeEvent event(
this
, d->value);
506
QAccessible::updateAccessibility(&event);
507
#
endif
508
sliderChange(SliderValueChange);
509
510
if
(emitValueChanged)
511
emit valueChanged(value);
512
513
}
514
515
/*!
516
\property QAbstractSlider::invertedAppearance
517
\brief whether or not a slider shows its values inverted.
518
519
If this property is \c false (the default), the minimum and maximum will
520
be shown in its classic position for the inherited widget. If the
521
value is true, the minimum and maximum appear at their opposite location.
522
523
Note: This property makes most sense for sliders and dials. For
524
scroll bars, the visual effect of the scroll bar subcontrols depends on
525
whether or not the styles understand inverted appearance; most styles
526
ignore this property for scroll bars.
527
*/
528
529
bool
QAbstractSlider::invertedAppearance()
const
530
{
531
Q_D(
const
QAbstractSlider);
532
return
d->invertedAppearance;
533
}
534
535
void
QAbstractSlider::setInvertedAppearance(
bool
invert)
536
{
537
Q_D(QAbstractSlider);
538
d->invertedAppearance = invert;
539
update();
540
}
541
542
543
/*!
544
\property QAbstractSlider::invertedControls
545
\brief whether or not the slider inverts its wheel and key events.
546
547
If this property is \c false, scrolling the mouse wheel "up" and using keys
548
like page up will increase the slider's value towards its maximum. Otherwise
549
pressing page up will move value towards the slider's minimum.
550
*/
551
552
553
bool
QAbstractSlider::invertedControls()
const
554
{
555
Q_D(
const
QAbstractSlider);
556
return
d->invertedControls;
557
}
558
559
void
QAbstractSlider::setInvertedControls(
bool
invert)
560
{
561
Q_D(QAbstractSlider);
562
d->invertedControls = invert;
563
}
564
565
/*! Triggers a slider \a action. Possible actions are \l
566
SliderSingleStepAdd, \l SliderSingleStepSub, \l SliderPageStepAdd,
567
\l SliderPageStepSub, \l SliderToMinimum, \l SliderToMaximum, and \l
568
SliderMove.
569
570
\sa actionTriggered()
571
*/
572
void
QAbstractSlider::triggerAction(SliderAction action)
573
{
574
Q_D(QAbstractSlider);
575
d->blocktracking =
true
;
576
switch
(action) {
577
case
SliderSingleStepAdd:
578
setSliderPosition(d->overflowSafeAdd(d->effectiveSingleStep()));
579
break
;
580
case
SliderSingleStepSub:
581
setSliderPosition(d->overflowSafeAdd(-d->effectiveSingleStep()));
582
break
;
583
case
SliderPageStepAdd:
584
setSliderPosition(d->overflowSafeAdd(d->pageStep));
585
break
;
586
case
SliderPageStepSub:
587
setSliderPosition(d->overflowSafeAdd(-d->pageStep));
588
break
;
589
case
SliderToMinimum:
590
setSliderPosition(d->minimum);
591
break
;
592
case
SliderToMaximum:
593
setSliderPosition(d->maximum);
594
break
;
595
case
SliderMove:
596
case
SliderNoAction:
597
break
;
598
};
599
emit actionTriggered(action);
600
d->blocktracking =
false
;
601
setValue(d->position);
602
}
603
604
/*! Sets action \a action to be triggered repetitively in intervals
605
of \a repeatTime, after an initial delay of \a thresholdTime.
606
607
\sa triggerAction(), repeatAction()
608
*/
609
void
QAbstractSlider::setRepeatAction(SliderAction action,
int
thresholdTime,
int
repeatTime)
610
{
611
Q_D(QAbstractSlider);
612
if
((d->repeatAction = action) == SliderNoAction) {
613
d->repeatActionTimer.stop();
614
}
else
{
615
d->repeatActionTime = repeatTime;
616
d->repeatActionTimer.start(thresholdTime,
this
);
617
}
618
}
619
620
/*!
621
Returns the current repeat action.
622
\sa setRepeatAction()
623
*/
624
QAbstractSlider::SliderAction QAbstractSlider::repeatAction()
const
625
{
626
Q_D(
const
QAbstractSlider);
627
return
d->repeatAction;
628
}
629
630
/*!\reimp
631
*/
632
void
QAbstractSlider::timerEvent(QTimerEvent *e)
633
{
634
Q_D(QAbstractSlider);
635
if
(e->timerId() == d->repeatActionTimer.timerId()) {
636
if
(d->repeatActionTime) {
// was threshold time, use repeat time next time
637
d->repeatActionTimer.start(d->repeatActionTime,
this
);
638
d->repeatActionTime = 0;
639
}
640
if
(d->repeatAction == SliderPageStepAdd)
641
d->setAdjustedSliderPosition(d->overflowSafeAdd(d->pageStep));
642
else
if
(d->repeatAction == SliderPageStepSub)
643
d->setAdjustedSliderPosition(d->overflowSafeAdd(-d->pageStep));
644
else
645
triggerAction(d->repeatAction);
646
}
647
}
648
649
/*!
650
Reimplement this virtual function to track slider changes such as
651
\l SliderRangeChange, \l SliderOrientationChange, \l
652
SliderStepsChange, or \l SliderValueChange. The default
653
implementation only updates the display and ignores the \a change
654
parameter.
655
*/
656
void
QAbstractSlider::sliderChange(SliderChange)
657
{
658
update();
659
}
660
661
bool
QAbstractSliderPrivate::scrollByDelta(Qt::Orientation orientation, Qt::KeyboardModifiers modifiers,
int
delta)
662
{
663
Q_Q(QAbstractSlider);
664
int
stepsToScroll = 0;
665
// in Qt scrolling to the right gives negative values.
666
if
(orientation == Qt::Horizontal)
667
delta = -delta;
668
qreal offset = qreal(delta) / 120;
669
670
if
((modifiers & Qt::ControlModifier) || (modifiers & Qt::ShiftModifier)) {
671
// Scroll one page regardless of delta:
672
stepsToScroll = qBound(-pageStep,
int
(offset * pageStep), pageStep);
673
offset_accumulated = 0;
674
}
else
{
675
// Calculate how many lines to scroll. Depending on what delta is (and
676
// offset), we might end up with a fraction (e.g. scroll 1.3 lines). We can
677
// only scroll whole lines, so we keep the reminder until next event.
678
qreal stepsToScrollF =
679
#
if
QT_CONFIG
(
wheelevent
)
680
QApplication::wheelScrollLines() *
681
#
endif
682
offset * effectiveSingleStep();
683
// Check if wheel changed direction since last event:
684
if
(offset_accumulated != 0 && (offset / offset_accumulated) < 0)
685
offset_accumulated = 0;
686
687
offset_accumulated += stepsToScrollF;
688
689
// Don't scroll more than one page in any case:
690
stepsToScroll = qBound(-pageStep,
int
(offset_accumulated), pageStep);
691
692
offset_accumulated -=
int
(offset_accumulated);
693
if
(stepsToScroll == 0) {
694
// We moved less than a line, but might still have accumulated partial scroll,
695
// unless we already are at one of the ends.
696
const
float
effective_offset = invertedControls ? -offset_accumulated : offset_accumulated;
697
if
(effective_offset > 0.f && value < maximum)
698
return
true
;
699
if
(effective_offset < 0.f && value > minimum)
700
return
true
;
701
offset_accumulated = 0;
702
return
false
;
703
}
704
}
705
706
if
(invertedControls)
707
stepsToScroll = -stepsToScroll;
708
709
int
prevValue = value;
710
position = bound(overflowSafeAdd(stepsToScroll));
// value will be updated by triggerAction()
711
q->triggerAction(QAbstractSlider::SliderMove);
712
713
if
(prevValue == value) {
714
offset_accumulated = 0;
715
return
false
;
716
}
717
return
true
;
718
}
719
720
/*!
721
\reimp
722
*/
723
#
if
QT_CONFIG
(
wheelevent
)
724
void
QAbstractSlider::wheelEvent(QWheelEvent * e)
725
{
726
Q_D(QAbstractSlider);
727
e->ignore();
728
bool
vertical =
bool
(e->angleDelta().y());
729
int
delta = vertical ? e->angleDelta().y() : e->angleDelta().x();
730
if
(e->inverted())
731
delta = -delta;
732
if
(d->scrollByDelta(vertical ? Qt::Vertical : Qt::Horizontal, e->modifiers(), delta))
733
e->accept();
734
}
735
736
#
endif
737
738
/*!
739
\reimp
740
*/
741
void
QAbstractSlider::keyPressEvent(QKeyEvent *ev)
742
{
743
Q_D(QAbstractSlider);
744
SliderAction action = SliderNoAction;
745
746
switch
(ev->key()) {
747
case
Qt::Key_Left:
748
if
(isRightToLeft())
749
action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd;
750
else
751
action = !d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd;
752
break
;
753
case
Qt::Key_Right:
754
if
(isRightToLeft())
755
action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub;
756
else
757
action = !d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub;
758
break
;
759
case
Qt::Key_Up:
760
action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd;
761
break
;
762
case
Qt::Key_Down:
763
action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub;
764
break
;
765
case
Qt::Key_PageUp:
766
action = d->invertedControls ? SliderPageStepSub : SliderPageStepAdd;
767
break
;
768
case
Qt::Key_PageDown:
769
action = d->invertedControls ? SliderPageStepAdd : SliderPageStepSub;
770
break
;
771
case
Qt::Key_Home:
772
action = SliderToMinimum;
773
break
;
774
case
Qt::Key_End:
775
action = SliderToMaximum;
776
break
;
777
default
:
778
ev->ignore();
779
break
;
780
}
781
if
(action)
782
triggerAction(action);
783
}
784
785
/*!
786
\reimp
787
*/
788
void
QAbstractSlider::changeEvent(QEvent *ev)
789
{
790
Q_D(QAbstractSlider);
791
switch
(ev->type()) {
792
case
QEvent::EnabledChange:
793
if
(!isEnabled()) {
794
d->repeatActionTimer.stop();
795
setSliderDown(
false
);
796
}
797
Q_FALLTHROUGH();
798
default
:
799
QWidget::changeEvent(ev);
800
}
801
}
802
803
/*!
804
\reimp
805
*/
806
bool
QAbstractSlider::event(QEvent *e)
807
{
808
return
QWidget::event(e);
809
}
810
811
// This function is called from itemviews when doing scroll per pixel (on updateGeometries())
812
// It will not have any effect if there has been a call to setSingleStep with
813
// a 'reasonable' value (since viewMayChangeSingleStep will be set to false).
814
// (If setSingleStep is called with -1 it will however allow the views to change singleStep.)
815
816
void
QAbstractSliderPrivate::itemviewChangeSingleStep(
int
step)
817
{
818
singleStepFromItemView = step;
819
if
(viewMayChangeSingleStep && singleStep != step)
820
setSteps(step, pageStep);
821
}
822
823
QT_END_NAMESPACE
824
825
#
include
"moc_qabstractslider.cpp"
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtbase
src
widgets
widgets
qabstractslider.cpp
Generated on
for Qt by
1.18.0