From ea318d1431c89e647598c510c4245c6571aa5f46 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 26 Jan 2012 23:32:43 -0600 Subject: Update to latest tqt3 automated conversion --- doc/html/ntqspinbox.html | 561 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 561 insertions(+) create mode 100644 doc/html/ntqspinbox.html (limited to 'doc/html/ntqspinbox.html') diff --git a/doc/html/ntqspinbox.html b/doc/html/ntqspinbox.html new file mode 100644 index 000000000..02b334959 --- /dev/null +++ b/doc/html/ntqspinbox.html @@ -0,0 +1,561 @@ + + + + + +TQSpinBox Class + + + + + + + +
+ +Home + | +All Classes + | +Main Classes + | +Annotated + | +Grouped Classes + | +Functions +

TQSpinBox Class Reference

+ +

The TQSpinBox class provides a spin box widget (spin button). +More... +

#include <ntqspinbox.h> +

Inherits TQWidget and TQRangeControl. +

List of all member functions. +

Public Members

+ +

Public Slots

+ +

Signals

+ +

Properties

+ +

Protected Members

+ +

Protected Slots

+ +

Detailed Description

+ + +The TQSpinBox class provides a spin box widget (spin button). +

+ +

TQSpinBox 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. If the value is +entered directly into the spin box, Enter (or Return) must be +pressed to apply the new value. The value is usually an integer. +

Every time the value changes TQSpinBox emits the valueChanged() +signal. The current value can be fetched with value() and set +with setValue(). +

The spin box keeps the value within a numeric range, and to +multiples of the lineStep() size (see TQRangeControl for details). +Clicking the up/down buttons or using the keyboard accelerator's +up and down arrows will increase or decrease the current value in +steps of size lineStep(). The minimum and maximum value and the +step size can be set using one of the constructors, and can be +changed later with setMinValue(), setMaxValue() and setLineStep(). +

Most spin boxes are directional, but TQSpinBox 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. +

The displayed value can be prepended and appended with arbitrary +strings indicating, for example, currency or the unit of +measurement. See setPrefix() and setSuffix(). The text in the spin +box is retrieved with text() (which includes any prefix() and +suffix()), or with cleanText() (which has no prefix(), no suffix() +and no leading or trailing whitespace). currentValueText() returns +the spin box's current value as text. +

Normally the spin box displays up and down arrows in the buttons. +You can use setButtonSymbols() to change the display to show ++ and - symbols if you prefer. In either case the up +and down arrow keys work as expected. +

It 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 TQSpinBox. +

The default TQWidget::focusPolicy() is StrongFocus. +

If using prefix(), suffix() and specialValueText() don't provide +enough control, you can ignore them and subclass TQSpinBox instead. +

TQSpinBox can easily be subclassed to allow the user to input +things other than an integer value as long as the allowed input +can be mapped 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 functions could be changed so that the user +provided values from 0.0 to 10.0, or -1 to signify 'Auto', while +the range of integers used inside the program would be -1 to 100: +

+        class MySpinBox : public TQSpinBox
+        {
+            Q_OBJECT
+        public:
+            ...
+
+            TQString mapValueToText( int value )
+            {
+                if ( value == -1 ) // special case
+                    return TQString( "Auto" );
+
+                return TQString( "%1.%2" ) // 0.0 to 10.0
+                    .arg( value / 10 ).arg( value % 10 );
+            }
+
+            int mapTextToValue( bool *ok )
+            {
+                if ( text() == "Auto" ) // special case
+                    return -1;
+
+                return (int) ( 10 * text().toFloat() ); // 0 to 100
+            }
+        };
+    
+ +

+

See also TQScrollBar, TQSlider, GUI Design Handbook: Spin Box, and Basic Widgets. + +


Member Type Documentation

+

TQSpinBox::ButtonSymbols

+ +

This enum type determines what the buttons in a spin box show. +

See also TQSpinBox::buttonSymbols. + +


Member Function Documentation

+

TQSpinBox::TQSpinBox ( TQWidget * parent = 0, const char * name = 0 ) +

+Constructs a spin box with the default TQRangeControl range and +step values. It is called name and has parent parent. +

See also minValue, maxValue, setRange(), lineStep, and setSteps(). + +

TQSpinBox::TQSpinBox ( int minValue, int maxValue, int step = 1, TQWidget * parent = 0, const char * name = 0 ) +

+Constructs a spin box that allows values from minValue to maxValue inclusive, with step amount step. The value is +initially set to minValue. +

The spin box is called name and has parent parent. +

See also minValue, maxValue, setRange(), lineStep, and setSteps(). + +

TQSpinBox::~TQSpinBox () +

+Destroys the spin box, freeing all memory and other resources. + +

ButtonSymbols TQSpinBox::buttonSymbols () const +

Returns the current button symbol mode. +See the "buttonSymbols" property for details. +

TQString TQSpinBox::cleanText () const [virtual] +

Returns the spin box's text with no prefix(), suffix() or leading or trailing whitespace. +See the "cleanText" property for details. +

TQString TQSpinBox::currentValueText () [protected] +

+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. + +

TQRect TQSpinBox::downRect () const +

+Returns the geometry of the "down" button. + +

TQLineEdit * TQSpinBox::editor () const [protected] +

+Returns a pointer to the embedded TQLineEdit. + +

bool TQSpinBox::eventFilter ( TQObject * o, TQEvent * ev ) [virtual protected] +

+Intercepts and handles the events coming to the embedded TQLineEdit +that have special meaning for the TQSpinBox. The object is passed +as o and the event is passed as ev. + +

Reimplemented from TQObject. +

void TQSpinBox::interpretText () [virtual protected] +

+TQSpinBox calls this after the user has manually edited the +contents of the spin box (i.e. by typing in the embedded +TQLineEdit, rather than using the up/down buttons/keys). +

The 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. +

See also editor(). + +

int TQSpinBox::lineStep () const +

Returns the line step. +See the "lineStep" property for details. +

int TQSpinBox::mapTextToValue ( bool * ok ) [virtual protected] +

+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 ok is not 0: if it parses the text +successfully, *ok is set to TRUE; otherwise *ok is set to +FALSE. +

Subclasses that need to display spin box values in a non-numeric +way need to reimplement this function. +

Note that TQt handles specialValueText() separately; this function +is only concerned with the other values. +

The default implementation tries to interpret the text() as an +integer in the standard way and returns the integer value. +

See also interpretText() and mapValueToText(). + +

TQString TQSpinBox::mapValueToText ( int v ) [virtual protected] +

+This virtual function is used by the spin box whenever it needs to +display value v. The default implementation returns a string +containing v printed in the standard way. Reimplementations may +return anything. (See the example in the detailed description.) +

Note that TQt does not call this function for specialValueText() +and that neither prefix() nor suffix() are included in the return +value. +

If you reimplement this, you may also need to reimplement +mapTextToValue(). +

See also updateDisplay() and mapTextToValue(). + +

int TQSpinBox::maxValue () const +

Returns the maximum value of the spin box. +See the "maxValue" property for details. +

int TQSpinBox::minValue () const +

Returns the minimum value of the spin box. +See the "minValue" property for details. +

TQString TQSpinBox::prefix () const [virtual] +

Returns the spin box's prefix. +See the "prefix" property for details. +

void TQSpinBox::rangeChange () [virtual protected] +

+This virtual function is called by TQRangeControl whenever the +range has changed. It adjusts the default validator and updates +the display; if you need additional processing, you can +reimplement this function. + +

Reimplemented from TQRangeControl. +

void TQSpinBox::selectAll () [virtual slot] +

+Selects all the text in the spin box's editor. + +

void TQSpinBox::setButtonSymbols ( ButtonSymbols ) [virtual] +

Sets the current button symbol mode. +See the "buttonSymbols" property for details. +

void TQSpinBox::setLineStep ( int ) +

Sets the line step. +See the "lineStep" property for details. +

void TQSpinBox::setMaxValue ( int ) +

Sets the maximum value of the spin box. +See the "maxValue" property for details. +

void TQSpinBox::setMinValue ( int ) +

Sets the minimum value of the spin box. +See the "minValue" property for details. +

void TQSpinBox::setPrefix ( const TQString & text ) [virtual slot] +

Sets the spin box's prefix to text. +See the "prefix" property for details. +

void TQSpinBox::setSpecialValueText ( const TQString & text ) [virtual] +

Sets the special-value text to text. +See the "specialValueText" property for details. +

void TQSpinBox::setSuffix ( const TQString & text ) [virtual slot] +

Sets the suffix of the spin box to text. +See the "suffix" property for details. +

void TQSpinBox::setValidator ( const TQValidator * v ) [virtual] +

+Sets the validator to v. The validator controls what keyboard +input is accepted when the user is editing in the value field. The +default is to use a suitable TQIntValidator. +

Use setValidator(0) to turn off input validation (entered input +will still be kept within the spin box's range). + +

void TQSpinBox::setValue ( int value ) [virtual slot] +

Sets the value of the spin box to value. +See the "value" property for details. +

void TQSpinBox::setWrapping ( bool on ) [virtual] +

Sets whether it is possible to step the value from the highest value to the lowest value and vice versa to on. +See the "wrapping" property for details. +

TQString TQSpinBox::specialValueText () const +

Returns the special-value text. +See the "specialValueText" property for details. +

void TQSpinBox::stepDown () [virtual slot] +

+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. +

See also stepUp(), subtractLine(), lineStep, setSteps(), value, and value. + +

void TQSpinBox::stepUp () [virtual slot] +

+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. +

See also stepDown(), addLine(), lineStep, setSteps(), value, and value. + +

TQString TQSpinBox::suffix () const [virtual] +

Returns the suffix of the spin box. +See the "suffix" property for details. +

TQString TQSpinBox::text () const +

Returns the spin box's text, including any prefix() and suffix(). +See the "text" property for details. +

void TQSpinBox::textChanged () [protected slot] +

+This slot is called whenever the user edits the spin box's text. + +

TQRect TQSpinBox::upRect () const +

+Returns the geometry of the "up" button. + +

void TQSpinBox::updateDisplay () [virtual protected] +

+Updates the contents of the embedded TQLineEdit to reflect the +current value using mapValueToText(). Also enables/disables the +up/down push buttons accordingly. +

See also mapValueToText(). + +

const TQValidator * TQSpinBox::validator () const +

+Returns the validator that constrains editing for this spin box if +there is any; otherwise returns 0. +

See also setValidator() and TQValidator. + +

int TQSpinBox::value () const +

Returns the value of the spin box. +See the "value" property for details. +

void TQSpinBox::valueChange () [virtual protected] +

+This virtual function is called by TQRangeControl whenever the +value has changed. The TQSpinBox 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. + +

Reimplemented from TQRangeControl. +

void TQSpinBox::valueChanged ( int value ) [signal] +

+ +

This signal is emitted every time the value of the spin box +changes; the new value is passed in value. 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. +

Note that the valueChanged() signal is emitted every time, not +just for the "last" step; i.e. if the user clicks "up" three +times, this signal is emitted three times. +

See also value. + +

Examples: listbox/listbox.cpp, qfd/fontdisplayer.cpp, and scribble/scribble.cpp. +

void TQSpinBox::valueChanged ( const TQString & valueText ) [signal] +

+ +

This is an overloaded member function, provided for convenience. It behaves essentially like the above function. +

This 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.). +

The valueText parameter is the same string that is displayed in +the edit field of the spin box. +

See also value, prefix, suffix, and specialValueText. + +

bool TQSpinBox::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. +


Property Documentation

+

ButtonSymbols buttonSymbols

+

This property holds the current button symbol mode. +

The possible values can be either UpDownArrows or PlusMinus. +The default is UpDownArrows. +

See also ButtonSymbols. + +

Set this property's value with setButtonSymbols() and get this property's value with buttonSymbols(). +

TQString cleanText

+

This property holds the spin box's text with no prefix(), suffix() or leading or trailing whitespace. +

Get this property's value with cleanText(). +

See also text, prefix, and suffix. + +

int lineStep

+

This property holds the line step. +

When 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. +

The setLineStep() function calls the virtual stepChange() function +if the new line step is different from the previous setting. +

See also TQRangeControl::setSteps() and setRange(). + +

Set this property's value with setLineStep() and get this property's value with lineStep(). +

int maxValue

+

This property holds the maximum value of the spin box. +

When setting this property, TQSpinBox::minValue is adjusted, if +necessary, to ensure that the range remains valid. +

See also setRange() and specialValueText. + +

Set this property's value with setMaxValue() and get this property's value with maxValue(). +

int minValue

+

This property holds the minimum value of the spin box. +

When setting this property, TQSpinBox::maxValue is adjusted, if +necessary, to ensure that the range remains valid. +

See also setRange() and specialValueText. + +

Set this property's value with setMinValue() and get this property's value with minValue(). +

TQString prefix

+

This property holds the spin box's prefix. +

The 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: +

+        sb->setPrefix( "$" );
+    
+ +

To 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. +

If no prefix is set, prefix() returns TQString::null. +

See also suffix. + +

Set this property's value with setPrefix() and get this property's value with prefix(). +

TQString specialValueText

+

This property holds the special-value text. +

If 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. +

For 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: +

+        TQSpinBox marginBox( -1, 20, 1, parent, "marginBox" );
+        marginBox->setSuffix( " mm" );
+        marginBox->setSpecialValueText( "Auto" );
+    
+ +The 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. +

All values are displayed with the prefix() and suffix() (if set), +except for the special value, which only shows the special +value text. +

To 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. +

If no special-value text is set, specialValueText() returns +TQString::null. + +

Set this property's value with setSpecialValueText() and get this property's value with specialValueText(). +

TQString suffix

+

This property holds the suffix of the spin box. +

The 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: +

+        sb->setSuffix( " km" );
+    
+ +

To 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. +

If no suffix is set, suffix() returns a TQString::null. +

See also prefix. + +

Set this property's value with setSuffix() and get this property's value with suffix(). +

TQString text

+

This property holds the spin box's text, including any prefix() and suffix(). +

There is no default text. +

See also value. + +

Get this property's value with text(). +

int value

+

This property holds the value of the spin box. +

Set this property's value with setValue() and get this property's value with value(). +

See also TQRangeControl::setValue(). + +

bool wrapping

+

This property holds whether it is possible to step the value from the highest value to the lowest value and vice versa. +

By default, wrapping is turned off. +

If 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. +

See also minValue, maxValue, and setRange(). + +

Set this property's value with setWrapping() and get this property's value with wrapping(). + +


+This file is part of the TQt toolkit. +Copyright © 1995-2007 +Trolltech. All Rights Reserved.


+ +
Copyright © 2007 +TrolltechTrademarks +
TQt 3.3.8
+
+ -- cgit v1.2.3