snakerst
3rd March 2010, 14:11
Hi,
I enter a value in my QTimeEdit like 900 ( displayformat hhmm) so this value is 09:00, but i want in my widget that the value is 09:00 and not 0900.
With the format hh:mm, we can't entered directly 900...
Someone has an idea ?
My code :
#include "TimeEdit.h"
#include <QTime>
TimeEdit::TimeEdit( QWidget * parent )
: QTimeEdit( parent )
{
setDisplayFormat( "hhmm" );
setCorrectionMode( QAbstractSpinBox::CorrectToNearestValue );
}
TimeEdit::~TimeEdit()
{
}
int TimeEdit::minutes() const
{
return time().hour() * 60 + time().minute();
}
void TimeEdit::setMinutes( int minutes )
{
setTime( QTime( minutes / 60, minutes % 60, 0 ) );
}
I enter a value in my QTimeEdit like 900 ( displayformat hhmm) so this value is 09:00, but i want in my widget that the value is 09:00 and not 0900.
With the format hh:mm, we can't entered directly 900...
Someone has an idea ?
My code :
#include "TimeEdit.h"
#include <QTime>
TimeEdit::TimeEdit( QWidget * parent )
: QTimeEdit( parent )
{
setDisplayFormat( "hhmm" );
setCorrectionMode( QAbstractSpinBox::CorrectToNearestValue );
}
TimeEdit::~TimeEdit()
{
}
int TimeEdit::minutes() const
{
return time().hour() * 60 + time().minute();
}
void TimeEdit::setMinutes( int minutes )
{
setTime( QTime( minutes / 60, minutes % 60, 0 ) );
}