📄 qspinbox.3qt
字号:
'\" t.TH QSpinBox 3qt "24 January 2005" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQSpinBox \- Spin box widget, sometimes called up-down widget, little arrows widget or spin button.br.PP\fC#include <qspinbox.h>\fR.PPInherits QFrame and QRangeControl..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQSpinBox\fR ( QWidget * " "parent" " = 0, const char * " "name" " = 0 ) ".br.ti -1c.BI "\fBQSpinBox\fR ( int " "minValue" ", int " "maxValue" ", int " "step" " = 1, QWidget * " "parent" " = 0, const char * " "name" " = 0 ) ".br.ti -1c.BI "\fB~QSpinBox\fR () ".br.ti -1c.BI "QString \fBtext\fR () const".br.ti -1c.BI "virtual QString \fBprefix\fR () const".br.ti -1c.BI "virtual QString \fBsuffix\fR () const".br.ti -1c.BI "virtual QString \fBcleanText\fR () const".br.ti -1c.BI "virtual void \fBsetSpecialValueText\fR ( const QString & text ) ".br.ti -1c.BI "QString \fBspecialValueText\fR () const".br.ti -1c.BI "virtual void \fBsetWrapping\fR ( bool on ) ".br.ti -1c.BI "bool \fBwrapping\fR () const".br.ti -1c.BI "enum \fBButtonSymbols\fR { UpDownArrows, PlusMinus }".br.ti -1c.BI "void \fBsetButtonSymbols\fR ( ButtonSymbols ) ".br.ti -1c.BI "ButtonSymbols \fBbuttonSymbols\fR () const".br.ti -1c.BI "virtual void \fBsetValidator\fR ( const QValidator * v ) ".br.ti -1c.BI "const QValidator* \fBvalidator\fR () const".br.ti -1c.BI "void \fBsetMinValue\fR ( int ) ".br.ti -1c.BI "void \fBsetMaxValue\fR ( int ) ".br.ti -1c.BI "void \fBsetLineStep\fR ( int ) ".br.in -1c.SS "Public Slots".in +1c.ti -1c.BI "virtual void \fBsetValue\fR ( int value ) ".br.ti -1c.BI "virtual void \fBsetPrefix\fR ( const QString & text ) ".br.ti -1c.BI "virtual void \fBsetSuffix\fR ( const QString & text ) ".br.ti -1c.BI "virtual void \fBstepUp\fR () ".br.ti -1c.BI "virtual void \fBstepDown\fR () ".br.in -1c.SS "Signals".in +1c.ti -1c.BI "void \fBvalueChanged\fR ( int value ) ".br.ti -1c.BI "void \fBvalueChanged\fR ( const QString & valueText ) ".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual QString \fBmapValueToText\fR ( int value ) ".br.ti -1c.BI "virtual int \fBmapTextToValue\fR ( bool * ok ) ".br.ti -1c.BI "QString \fBcurrentValueText\fR () ".br.ti -1c.BI "virtual void \fBupdateDisplay\fR () ".br.ti -1c.BI "virtual void \fBinterpretText\fR () ".br.ti -1c.BI "QPushButton* \fBupButton\fR () const".br.ti -1c.BI "QPushButton* \fBdownButton\fR () const".br.ti -1c.BI "QLineEdit* \fBeditor\fR () const".br.ti -1c.BI "virtual void \fBvalueChange\fR () ".br.ti -1c.BI "virtual void \fBrangeChange\fR () ".br.ti -1c.BI "virtual bool \fBeventFilter\fR ( QObject * " "obj" ", QEvent * ev ) ".br.in -1c.SS "Protected Slots".in +1c.ti -1c.BI "void \fBtextChanged\fR () ".br.in -1c.SS "Properties".nf.TSl l l l l- - - - -l l l l l.Type Name READ WRITE OptionsQString text textQString prefix prefix setPrefixQString suffix suffix setSuffixQString cleanText cleanTextQString specialValueText specialValueText setSpecialValueTextbool wrapping wrapping setWrappingButtonSymbols buttonSymbols buttonSymbols setButtonSymbolsint maxValue maxValue setMaxValueint minValue minValue setMinValueint lineStep lineStep setLineStepint value value setValue.TE.fi.SH DESCRIPTIONThe QSpinBox class provides a spin box widget, sometimes called up-down widget, little arrows widget or spin button..PPQSpinBox allows the user to choose a value, either by clicking the up/down buttons to increase/decrease the value currently displayed, or by typing the value directly into the spin box. Usually the value is an integer..PPEvery time the value changes, QSpinBox emits the valueChanged() signal. The current value can be fetched with value() and set with setValue()..PPThe spin box clamps the value within a numeric range, see QRangeControl for details. Clicking the up/down down buttons (or using the keyboard accelerators: Up-arrow and Down-arrow) will increase or decrease the current value in steps of size lineStep()..PPMost spin boxes are directional, but QSpinBox can also operate as a circular spin box, i.e. if the range is 0-99 and the current value is 99, clicking Up will give 0. Use setWrapping() if you want circular behavior..PPThe displayed value can be prepended and/or appended with an arbitrary string indicating for example the unit of measurement. See setPrefix() and setSuffix()..PPNormally, the spin box displays up and down arrows in the buttons. You can use setButtonSymbols() to change the display to show + and - symbols, if this is clearer for your intended purpose. In either case, the up and down arrow keys always work..PPIt is often desirable to give the user a special, often default, choice in addition to the range of numeric values. See setSpecialValueText() for how to do this with QSpinBox..PPThe default QWidget::focusPolicy() is StrongFocus..PPQSpinBox can easily be subclassed to allow the user to input other things than an integer value, as long as the allowed input can be mapped down to a range of integers. This can be done by overriding the virtual functions mapValueToText() and mapTextToValue() and setting another, suitable validator using setValidator(). For example, these function could be changed so that the user provided values from 0.0 to 10.0 while the range of integers used inside the program would be 0 to 100:.PP.nf.br class MySpinBox : public QSpinBox {.br public:.br ....br.br QString mapValueToText( int value ).br {.br return QString("%1.%2").arg(value/10).arg(value%10);.br }.br.br int mapTextToValue( bool* ok ).br {.br return int(text().toFloat()*10);.br }.br.br };.fi.PP.ce 1.B "[Image Omitted]".PP.ce 1.B "[Image Omitted]".PPSee also QScrollBar, QSlider and GUI Design Handbook: Spin Box.SS "Member Type Documentation".SH "QSpinBox::ButtonSymbols"This enum type determines what the buttons in a spin box show. The currently defined values are: .TP\fCUpDownArrows\fR - the buttons show little arrows, in the classic style. This is the default.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -