QDial Class
The QDial 提供一个圆形范围控制(如速度计或电位器). 更多...
头文件: | #include <QDial> |
qmake: | QT += widgets |
基类: | QAbstractSlider |
属性
- notchSize : const int
- notchTarget : qreal
- notchesVisible : bool
- wrapping : bool
- 11 个属性继承自 QAbstractSlider
- 59 个属性继承自 QWidget
- 1 个属性继承自 QObject
公有函数
QDial(QWidget *parent = Q_NULLPTR) | |
~QDial() | |
int | notchSize() const |
qreal | notchTarget() const |
bool | notchesVisible() const |
void | setNotchTarget(double target) |
bool | wrapping() const |
重新实现的公有函数
virtual QSize | minimumSizeHint() const |
virtual QSize | sizeHint() const |
- 21 个公有函数继承自 QAbstractSlider
- 214 个公有函数继承自 QWidget
- 32 个公有函数继承自 QObject
- 14 个公有函数继承自 QPaintDevice
公有槽函数
void | setNotchesVisible(bool visible) |
void | setWrapping(bool on) |
- 3 个公有槽函数继承自 QAbstractSlider
- 19 个公有槽函数继承自 QWidget
- 1 个公有槽函数继承自 QObject
受保护的函数
void | initStyleOption(QStyleOptionSlider *option) const |
重新实现的受保护函数
virtual bool | event(QEvent *e) |
virtual void | mouseMoveEvent(QMouseEvent *e) |
virtual void | mousePressEvent(QMouseEvent *e) |
virtual void | mouseReleaseEvent(QMouseEvent *e) |
virtual void | paintEvent(QPaintEvent *pe) |
virtual void | resizeEvent(QResizeEvent *e) |
virtual void | sliderChange(SliderChange change) |
- 8 个受保护的函数继承自 QAbstractSlider
- 35 个受保护的函数继承自 QWidget
- 9 个受保护的函数继承自 QObject
- 1 个受保护的函数继承自 QPaintDevice
其他继承的成员
- 6 个信号继承自 QAbstractSlider
- 3 个信号继承自 QWidget
- 2 个信号继承自 QObject
- 1 个公有变量继承自 QObject
- 5 个静态公有成员继承自 QWidget
- 10 个静态公有成员继承自 QObject
- 1 个受保护的槽函数继承自 QWidget
- 2 个受保护的变量继承自 QObject
- 1 protected type inherited from QPaintDevice
详细描述
QDial 提供一个圆形范围控制(如速度计或电位器).
QDial 的应用场景: 用户需要控制一个软件可定义范围的值, 这个场景可能是环形范围(如0-360角度), 也有可能是正方形的widget.
QDial 继承自 QAbstractSlider, 表盘(Dial) 滑块 与类似. wrapping() 是false(默认设置)时, 表盘与滑块没有本质区别. 他们具有相同的信号, 槽函数和成员函数. 使用哪个取决于用户的需求及应用程序的类型.
滑块移动时, QDial不间断地发送 valueChanged() 信号; 禁用 tracking 属性减少valueChanged()信号频率. 即使禁用tracking属性, sliderMoved() 信号也会连续发送.
按下和释放鼠标时, QDial 会发送 sliderPressed() 和 sliderReleased() 信号. 注意: 使用键盘和滚轮改变表盘值时, 不会发送这些信号.
跟滑块不一样的地方是, QDial 不是每一步绘制一个刻度线, 而是尝试绘制一个"适宜"等级的刻度线. 如果可能, QDial 会每一步绘制一个刻度线, 但是如果没有足够的空间, QDial 采用统一标准绘制(例如.如每秒或三个刻度线绘制一次).
跟滑块一样, QDial从 QAbstractSlider 继承槽函数 setValue() .
表盘的键盘接口相当简单: left/up 和 right/down 依照singleStep定义修改控制表盘的 value, Page Up 和 Page Down 依照pageStep 定义修改控制表盘的 value, Home 和 End 将表盘值修改为定义的 minimum 和 maximum 值.
如果你使用鼠标滚轮调整表盘值, 则增量值由 wheelScrollLines 乘以 singleStep的结果, 和 pageStep的之间最小值决定.
![]() | ![]() | ![]() |
Dials shown in various widget styles (from left to right): Fusion, Windows Vista, Macintosh. |
参见 QScrollBar, QSpinBox, QSlider, GUI Design Handbook: Slider, and Sliders Example.
属性
notchSize : const int
This property holds the current notch size
The notch size is in range control units, not pixels, and if possible it is a multiple of singleStep() that results in an on-screen notch size near notchTarget().
By default, this property has a value of 1.
访问函数:
int | notchSize() const |
参见 notchTarget() and singleStep().
notchTarget : qreal
This property holds the target number of pixels between notches
The notch target is the number of pixels QDial attempts to put between each notch.
The actual size may differ from the target size.
The default notch target is 3.7 pixels.
访问函数:
qreal | notchTarget() const |
void | setNotchTarget(double target) |
notchesVisible : bool
This property holds whether the notches are shown
If the property is true
, a series of notches are drawn around the dial to indicate the range of values available; otherwise no notches are shown.
By default, this property is disabled.
访问函数:
bool | notchesVisible() const |
void | setNotchesVisible(bool visible) |
wrapping : bool
This property holds whether wrapping is enabled
If true, wrapping is enabled; otherwise some space is inserted at the bottom of the dial to separate the ends of the range of valid values.
If enabled, the arrow can be oriented at any angle on the dial. If disabled, the arrow will be restricted to the upper part of the dial; if it is rotated into the space at the bottom of the dial, it will be clamped to the closest end of the valid range of values.
By default this property is false
.
访问函数:
bool | wrapping() const |
void | setWrapping(bool on) |
成员函数
QDial::QDial(QWidget *parent = Q_NULLPTR)
Constructs a dial.
The parent argument is sent to the QAbstractSlider constructor.
QDial::~QDial()
Destroys the dial.
[virtual protected]
bool QDial::event(QEvent *e)
重新实现 QObject::event().
[protected]
void QDial::initStyleOption(QStyleOptionSlider *option) const
Initialize option with the values from this QDial. This method is useful for subclasses when they need a QStyleOptionSlider, but don't want to fill in all the information themselves.
参见 QStyleOption::initFrom().
[virtual]
QSize QDial::minimumSizeHint() const
重新实现 QWidget::minimumSizeHint().
[virtual protected]
void QDial::mouseMoveEvent(QMouseEvent *e)
重新实现 QWidget::mouseMoveEvent().
[virtual protected]
void QDial::mousePressEvent(QMouseEvent *e)
重新实现 QWidget::mousePressEvent().
[virtual protected]
void QDial::mouseReleaseEvent(QMouseEvent *e)
重新实现 QWidget::mouseReleaseEvent().
[virtual protected]
void QDial::paintEvent(QPaintEvent *pe)
重新实现 QWidget::paintEvent().
[virtual protected]
void QDial::resizeEvent(QResizeEvent *e)
重新实现 QWidget::resizeEvent().
[virtual]
QSize QDial::sizeHint() const
重新实现 QWidget::sizeHint().
[virtual protected]
void QDial::sliderChange(SliderChange change)
重新实现 QAbstractSlider::sliderChange().