📄 qspinbox.3qt
字号:
See also minValue, maxValue, setRange(), lineStep, and setSteps()..SH "QSpinBox::QSpinBox ( int minValue, int maxValue, int step = 1, QWidget * parent = 0, const char * name = 0 )"Constructs a spin box that allows values from \fIminValue\fR to \fImaxValue\fR inclusive, with step amount \fIstep\fR. The value is initially set to \fIminValue\fR..PPThe spin box is called \fIname\fR and has parent \fIparent\fR..PPSee also minValue, maxValue, setRange(), lineStep, and setSteps()..SH "QSpinBox::~QSpinBox ()"Destroys the spin box, freeing all memory and other resources..SH "ButtonSymbols QSpinBox::buttonSymbols () const"Returns the current button symbol mode. See the "buttonSymbols" property for details..SH "QString QSpinBox::cleanText () const\fC [virtual]\fR"Returns the spin box's text with no prefix(), suffix() or leading or trailing whitespace. See the "cleanText" property for details..SH "QString QSpinBox::currentValueText ()\fC [protected]\fR"Returns the full text calculated from the current value, including any prefix and suffix. If there is special value text and the value is minValue() the specialValueText() is returned..SH "QRect QSpinBox::downRect () const"Returns the geometry of the "down" button..SH "QLineEdit * QSpinBox::editor () const\fC [protected]\fR"Returns a pointer to the embedded QLineEdit..SH "bool QSpinBox::eventFilter ( QObject * o, QEvent * ev )\fC [virtual protected]\fR"Intercepts and handles the events coming to the embedded QLineEdit that have special meaning for the QSpinBox. The object is passed as \fIo\fR and the event is passed as \fIev\fR..PPReimplemented from QObject..SH "void QSpinBox::interpretText ()\fC [virtual protected]\fR"QSpinBox calls this after the user has manually edited the contents of the spin box (i.e. by typing in the embedded QLineEdit, rather than using the up/down buttons/keys)..PPThe default implementation of this function interprets the new text using mapTextToValue(). If mapTextToValue() is successful, it changes the spin box's value; if not, the value is left unchanged..PPSee also editor()..SH "int QSpinBox::lineStep () const"Returns the line step. See the "lineStep" property for details..SH "int QSpinBox::mapTextToValue ( bool * ok )\fC [virtual protected]\fR"This virtual function is used by the spin box whenever it needs to interpret text entered by the user as a value. The text is available as text() and as cleanText(), and this function must parse it if possible. If \fIok\fR is not 0: if it parses the text successfully, \fI*ok\fR is set to TRUE; otherwise \fI*ok\fR is set to FALSE..PPSubclasses that need to display spin box values in a non-numeric way need to reimplement this function..PPNote that Qt handles specialValueText() separately; this function is only concerned with the other values..PPThe default implementation tries to interpret the text() as an integer in the standard way and returns the integer value..PPSee also interpretText() and mapValueToText()..SH "QString QSpinBox::mapValueToText ( int v )\fC [virtual protected]\fR"This virtual function is used by the spin box whenever it needs to display value \fIv\fR. The default implementation returns a string containing \fIv\fR printed in the standard way. Reimplementations may return anything. (See the example in the detailed description.).PPNote that Qt does not call this function for specialValueText() and that neither prefix() nor suffix() are included in the return value..PPIf you reimplement this, you may also need to reimplement mapTextToValue()..PPSee also updateDisplay() and mapTextToValue()..SH "int QSpinBox::maxValue () const"Returns the maximum value of the spin box. See the "maxValue" property for details..SH "int QSpinBox::minValue () const"Returns the minimum value of the spin box. See the "minValue" property for details..SH "QString QSpinBox::prefix () const\fC [virtual]\fR"Returns the spin box's prefix. See the "prefix" property for details..SH "void QSpinBox::rangeChange ()\fC [virtual protected]\fR"This virtual function is called by QRangeControl whenever the range has changed. It adjusts the default validator and updates the display; if you need additional processing, you can reimplement this function..PPReimplemented from QRangeControl..SH "void QSpinBox::selectAll ()\fC [virtual slot]\fR"Selects all the text in the spin box's editor..SH "void QSpinBox::setButtonSymbols ( ButtonSymbols )\fC [virtual]\fR"Sets the current button symbol mode. See the "buttonSymbols" property for details..SH "void QSpinBox::setLineStep ( int )"Sets the line step. See the "lineStep" property for details..SH "void QSpinBox::setMaxValue ( int )"Sets the maximum value of the spin box. See the "maxValue" property for details..SH "void QSpinBox::setMinValue ( int )"Sets the minimum value of the spin box. See the "minValue" property for details..SH "void QSpinBox::setPrefix ( const QString & text )\fC [virtual slot]\fR"Sets the spin box's prefix to \fItext\fR. See the "prefix" property for details..SH "void QSpinBox::setSpecialValueText ( const QString & text )\fC [virtual]\fR"Sets the special-value text to \fItext\fR. See the "specialValueText" property for details..SH "void QSpinBox::setSuffix ( const QString & text )\fC [virtual slot]\fR"Sets the suffix of the spin box to \fItext\fR. See the "suffix" property for details..SH "void QSpinBox::setValidator ( const QValidator * v )\fC [virtual]\fR"Sets the validator to \fIv\fR. The validator controls what keyboard input is accepted when the user is editing in the value field. The default is to use a suitable QIntValidator..PPUse setValidator(0) to turn off input validation (entered input will still be kept within the spin box's range)..SH "void QSpinBox::setValue ( int value )\fC [virtual slot]\fR"Sets the value of the spin box to \fIvalue\fR. See the "value" property for details..SH "void QSpinBox::setWrapping ( bool on )\fC [virtual]\fR"Sets whether it is possible to step the value from the highest value to the lowest value and vice versa to \fIon\fR. See the "wrapping" property for details..SH "QString QSpinBox::specialValueText () const"Returns the special-value text. See the "specialValueText" property for details..SH "void QSpinBox::stepDown ()\fC [virtual slot]\fR"Decreases the spin box's value one lineStep(), wrapping as necessary if wrapping() is TRUE. This is the same as clicking on the pointing-down button and can be used for keyboard accelerators, for example..PPSee also stepUp(), subtractLine(), lineStep, setSteps(), value, and value..SH "void QSpinBox::stepUp ()\fC [virtual slot]\fR"Increases the spin box's value by one lineStep(), wrapping as necessary if wrapping() is TRUE. This is the same as clicking on the pointing-up button and can be used for keyboard accelerators, for example..PPSee also stepDown(), addLine(), lineStep, setSteps(), value, and value..SH "QString QSpinBox::suffix () const\fC [virtual]\fR"Returns the suffix of the spin box. See the "suffix" property for details..SH "QString QSpinBox::text () const"Returns the spin box's text, including any prefix() and suffix(). See the "text" property for details..SH "void QSpinBox::textChanged ()\fC [protected slot]\fR"This slot is called whenever the user edits the spin box's text..SH "QRect QSpinBox::upRect () const"Returns the geometry of the "up" button..SH "void QSpinBox::updateDisplay ()\fC [virtual protected]\fR"Updates the contents of the embedded QLineEdit to reflect the current value using mapValueToText(). Also enables/disables the up/down push buttons accordingly..PPSee also mapValueToText()..SH "const QValidator * QSpinBox::validator () const"Returns the validator that constrains editing for this spin box if there is any; otherwise returns 0..PPSee also setValidator() and QValidator..SH "int QSpinBox::value () const"Returns the value of the spin box. See the "value" property for details..SH "void QSpinBox::valueChange ()\fC [virtual protected]\fR"This virtual function is called by QRangeControl whenever the value has changed. The QSpinBox reimplementation updates the display and emits the valueChanged() signals; if you need additional processing, either reimplement this or connect to one of the valueChanged() signals..PPReimplemented from QRangeControl..SH "void QSpinBox::valueChanged ( int value )\fC [signal]\fR"This signal is emitted every time the value of the spin box changes; the new value is passed in \fIvalue\fR. This signal will be emitted as a result of a call to setValue(), or because the user changed the value by using a keyboard accelerator or mouse click, etc..PPNote that the valueChanged() signal is emitted \fIevery\fR time, not just for the "last" step; i.e. if the user clicks "up" three times, this signal is emitted three times..PPSee also value..PPExamples:.)l listbox/listbox.cpp, qfd/fontdisplayer.cpp, and scribble/scribble.cpp..SH "void QSpinBox::valueChanged ( const QString & valueText )\fC [signal]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis signal is emitted whenever the valueChanged( int ) signal is emitted, i.e. every time the value of the spin box changes (whatever the cause, e.g. by setValue(), by a keyboard accelerator, by mouse clicks, etc.)..PPThe \fIvalueText\fR parameter is the same string that is displayed in the edit field of the spin box..PPSee also value, prefix, suffix, and specialValueText..SH "bool QSpinBox::wrapping () const"Returns TRUE if it is possible to step the value from the highest value to the lowest value and vice versa; otherwise returns FALSE. See the "wrapping" property for details..SS "Property Documentation".SH "ButtonSymbols buttonSymbols"This property holds the current button symbol mode..PPThe possible values can be either UpDownArrows or PlusMinus. The default is UpDownArrows..PPSee also ButtonSymbols..PPSet this property's value with setButtonSymbols() and get this property's value with buttonSymbols()..SH "QString cleanText"This property holds the spin box's text with no prefix(), suffix() or leading or trailing whitespace..PPGet this property's value with cleanText()..PPSee also text, prefix, and suffix..SH "int lineStep"This property holds the line step..PPWhen the user uses the arrows to change the spin box's value the value will be incremented/decremented by the amount of the line step..PPThe setLineStep() function calls the virtual stepChange() function if the new line step is different from the previous setting..PPSee also QRangeControl::setSteps() and setRange()..PPSet this property's value with setLineStep() and get this property's value with lineStep()..SH "int maxValue"This property holds the maximum value of the spin box..PPWhen setting this property, QSpinBox::minValue is adjusted, if necessary, to ensure that the range remains valid..PPSee also setRange() and specialValueText..PPSet this property's value with setMaxValue() and get this property's value with maxValue()..SH "int minValue"This property holds the minimum value of the spin box..PPWhen setting this property, QSpinBox::maxValue is adjusted, if necessary, to ensure that the range remains valid..PPSee also setRange() and specialValueText..PPSet this property's value with setMinValue() and get this property's value with minValue()..SH "QString prefix"This property holds the spin box's prefix..PPThe prefix is prepended to the start of the displayed value. Typical use is to display a unit of measurement or a currency symbol. For example:.PP.nf.br sb->setPrefix( "$" );.br.fi.PPTo turn off the prefix display, set this property to an empty string. The default is no prefix. The prefix is not displayed for the minValue() if specialValueText() is not empty..PPIf no prefix is set, prefix() returns QString::null..PPSee also suffix..PPSet this property's value with setPrefix() and get this property's value with prefix()..SH "QString specialValueText"This property holds the special-value text..PPIf set, the spin box will display this text instead of a numeric value whenever the current value is equal to minVal(). Typical use is to indicate that this choice has a special (default) meaning..PPFor example, if your spin box allows the user to choose the margin width in a print dialog and your application is able to automatically choose a good margin width, you can set up the spin box like this:.PP.nf.br QSpinBox marginBox( -1, 20, 1, parent, "marginBox" );.br marginBox->setSuffix( " mm" );.br marginBox->setSpecialValueText( "Auto" );.br.fiThe user will then be able to choose a margin width from 0-20 millimeters or select "Auto" to leave it to the application to choose. Your code must then interpret the spin box value of -1 as the user requesting automatic margin width..PPAll values are displayed with the prefix() and suffix() (if set), \fIexcept\fR for the special value, which only shows the special value text..PPTo turn off the special-value text display, call this function with an empty string. The default is no special-value text, i.e. the numeric value is shown as usual..PPIf no special-value text is set, specialValueText() returns QString::null..PPSet this property's value with setSpecialValueText() and get this property's value with specialValueText()..SH "QString suffix"This property holds the suffix of the spin box..PPThe suffix is appended to the end of the displayed value. Typical use is to display a unit of measurement or a currency symbol. For example:.PP.nf.br sb->setSuffix( " km" );.br.fi.PPTo turn off the suffix display, set this property to an empty string. The default is no suffix. The suffix is not displayed for the minValue() if specialValueText() is not empty..PPIf no suffix is set, suffix() returns a QString::null..PPSee also prefix..PPSet this property's value with setSuffix() and get this property's value with suffix()..SH "QString text"This property holds the spin box's text, including any prefix() and suffix()..PPThere is no default text..PPSee also value..PPGet this property's value with text()..SH "int value"This property holds the value of the spin box..PPSet this property's value with setValue() and get this property's value with value()..PPSee also QRangeControl::setValue()..SH "bool wrapping"This property holds whether it is possible to step the value from the highest value to the lowest value and vice versa..PPBy default, wrapping is turned off..PPIf you have a range of 0..100 and wrapping is off when the user reaches 100 and presses the Up Arrow nothing will happen; but if wrapping is on the value will change from 100 to 0, then to 1, etc. When wrapping is on, navigating past the highest value takes you to the lowest and vice versa..PPSee also minValue, maxValue, and setRange()..PPSet this property's value with setWrapping() and get this property's value with wrapping()..SH "SEE ALSO".BR http://doc.trolltech.com/qspinbox.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qspinbox.3qt) and the Qtversion (3.1.1).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -