TQTimeEdit Class

Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# TQTimeEdit Class Reference

The TQTimeEdit class provides a time editor. More...

`#include <ntqdatetimeedit.h>`

Inherits TQDateTimeEditBase.

List of all member functions.

## Public Members

- enum Display { Hours = 0x01, Minutes = 0x02, Seconds = 0x04, AMPM = 0x10 }
- TQTimeEdit ( TQWidget * parent = 0, const char * name = 0 )
- TQTimeEdit ( const TQTime & time, TQWidget * parent = 0, const char * name = 0 )
- ~TQTimeEdit ()
- TQTime time () const
- virtual void setAutoAdvance ( bool advance )
- bool autoAdvance () const
- virtual void setMinValue ( const TQTime & d )
- TQTime minValue () const
- virtual void setMaxValue ( const TQTime & d )
- TQTime maxValue () const
- virtual void setRange ( const TQTime & min, const TQTime & max )
- TQString separator () const
- virtual void setSeparator ( const TQString & s )
- uint display () const
- void setDisplay ( uint disp )

## Public Slots

- virtual void setTime ( const TQTime & time )

## Signals

- void valueChanged ( const TQTime & time )

## Properties

- bool autoAdvance - whether the editor automatically advances to the next section
- Display display - the sections that are displayed in the time edit
- TQTime maxValue - the maximum time value
- TQTime minValue - the minimum time value
- TQTime time - the editor's time value

## Protected Members

- virtual TQString sectionFormattedText ( int sec )
- virtual void setHour ( int h )
- virtual void setMinute ( int m )
- virtual void setSecond ( int s )

## Detailed Description

The TQTimeEdit class provides a time editor.

TQTimeEdit allows the user to edit times by using the keyboard or the arrow keys to increase/decrease time values. The arrow keys can be used to move from section to section within the TQTimeEdit box. The user can automatically be moved to the next section once they complete a section using setAutoAdvance(). Times appear in hour, minute, second order. It is recommended that the TQTimeEdit is initialised with a time, e.g.

        TQTime timeNow = TQTime::currentTime();
        TQTimeEdit *timeEdit = new TQTimeEdit( timeNow, this );
        timeEdit->setRange( timeNow, timeNow.addSecs( 60 * 60 ) );

Here we've created a TQTimeEdit widget set to the current time. We've also set the minimum value to the current time and the maximum time to one hour from now.

The maximum and minimum values for a time value in the time editor default to the maximum and minimum values for a TQTime. You can change this by calling setMinValue(), setMaxValue() or setRange().

Terminology: A TQTimeWidget consists of three sections, one each for the hour, minute and second. You can change the separator character using setSeparator(), by default the separator is read from the system's settings.

See also TQTime, TQDateEdit, TQDateTimeEdit, Advanced Widgets, and Time and Date.

## Member Type Documentation

### TQTimeEdit::Display

This enum defines the sections that comprise a time

- `TQTimeEdit::Hours` - The hours section
- `TQTimeEdit::Minutes` - The minutes section
- `TQTimeEdit::Seconds` - The seconds section
- `TQTimeEdit::AMPM` - The AM/PM section

The values can be or'ed together to show any combination.

## Member Function Documentation

### TQTimeEdit::TQTimeEdit ( TQWidget * parent = 0, const char * name = 0 )

Constructs an empty time edit with parent parent and called name.

### TQTimeEdit::TQTimeEdit ( const TQTime & time, TQWidget * parent = 0, const char * name = 0 )

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

Constructs a time edit with the initial time value, time, parent parent and called name.

### TQTimeEdit::~TQTimeEdit ()

Destroys the object and frees any allocated resources.

### bool TQTimeEdit::autoAdvance () const

Returns true if the editor automatically advances to the next section; otherwise returns false. See the "autoAdvance" property for details.

### uint TQTimeEdit::display () const

Returns the sections that are displayed in the time edit. See the "display" property for details.

### TQTime TQTimeEdit::maxValue () const

Returns the maximum time value. See the "maxValue" property for details.

### TQTime TQTimeEdit::minValue () const

Returns the minimum time value. See the "minValue" property for details.

### TQString TQTimeEdit::sectionFormattedText ( int sec )`[virtual protected]`

Returns the formatted number for section sec. This will correspond to either the hour, minute or second section, depending on sec.

### TQString TQTimeEdit::separator () const

Returns the editor's separator.

### void TQTimeEdit::setAutoAdvance ( bool advance )`[virtual]`

Sets whether the editor automatically advances to the next section to advance. See the "autoAdvance" property for details.

### void TQTimeEdit::setDisplay ( uint disp )

Sets the sections that are displayed in the time edit to disp. See the "display" property for details.

### void TQTimeEdit::setHour ( int h )`[virtual protected]`

Sets the hour to h, which must be a valid hour, i.e. in the range 0..24.

### void TQTimeEdit::setMaxValue ( const TQTime & d )`[virtual]`

Sets the maximum time value to d. See the "maxValue" property for details.

### void TQTimeEdit::setMinValue ( const TQTime & d )`[virtual]`

Sets the minimum time value to d. See the "minValue" property for details.

### void TQTimeEdit::setMinute ( int m )`[virtual protected]`

Sets the minute to m, which must be a valid minute, i.e. in the range 0..59.

### void TQTimeEdit::setRange ( const TQTime & min, const TQTime & max )`[virtual]`

Sets the valid input range for the editor to be from min to max inclusive. If min is invalid no minimum time is set. Similarly, if max is invalid no maximum time is set.

### void TQTimeEdit::setSecond ( int s )`[virtual protected]`

Sets the second to s, which must be a valid second, i.e. in the range 0..59.

### void TQTimeEdit::setSeparator ( const TQString & s )`[virtual]`

Sets the separator to s. Note that currently only the first character of s is used.

### void TQTimeEdit::setTime ( const TQTime & time )`[virtual slot]`

Sets the editor's time value to time. See the "time" property for details.

### TQTime TQTimeEdit::time () const

Returns the editor's time value. See the "time" property for details.

### void TQTimeEdit::valueChanged ( const TQTime & time )`[signal]`

This signal is emitted whenever the editor's value changes. The time parameter is the new value.

## Property Documentation

### bool autoAdvance

This property holds whether the editor automatically advances to the next section.

If autoAdvance is true, the editor will automatically advance focus to the next time section if a user has completed a section. The default is false.

Set this property's value with setAutoAdvance() and get this property's value with autoAdvance().

### Display display

This property holds the sections that are displayed in the time edit.

The value can be any combination of the values in the Display enum. By default, the widget displays hours, minutes and seconds.

Set this property's value with setDisplay() and get this property's value with display().

### TQTime maxValue

This property holds the maximum time value.

Setting the maximum time value is equivalent to calling TQTimeEdit::setRange( minValue(), t ), where t is the maximum time. The default maximum time is 23:59:59.

See also minValue and setRange().

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

### TQTime minValue

This property holds the minimum time value.

Setting the minimum time value is equivalent to calling TQTimeEdit::setRange( t, maxValue() ), where t is the minimum time. The default minimum time is 00:00:00.

See also maxValue and setRange().

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

### TQTime time

This property holds the editor's time value.

When changing the time property, if the time is less than minValue(), or is greater than maxValue(), nothing happens.

Set this property's value with setTime() and get this property's value with time().

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