26 #define YUILogComponent "qt-ui"
27 #include <yui/YUILog.h>
29 #include <qdatetimeedit.h>
33 #include "YQTimeField.h"
34 #include "yui/YEvent.h"
35 #include "YQWidgetCaption.h"
36 #include <QVBoxLayout>
42 : QFrame( (QWidget *) parent->widgetRep() )
43 , YTimeField( parent, label )
46 QVBoxLayout* layout =
new QVBoxLayout(
this );
49 layout->setSpacing( YQWidgetSpacing );
50 layout->setMargin ( YQWidgetMargin );
53 YUI_CHECK_NEW( _caption );
54 layout->addWidget( _caption );
56 _qt_timeEdit =
new QTimeEdit(
this );
57 YUI_CHECK_NEW( _qt_timeEdit );
58 _qt_timeEdit->setDisplayFormat(
"hh:mm:ss");
59 layout->addWidget( _qt_timeEdit );
61 _caption->setBuddy( _qt_timeEdit );
63 connect( _qt_timeEdit, &QTimeEdit::timeChanged,
64 this, &YQTimeField::changed);
76 return toUTF8( _qt_timeEdit->time().toString( Qt::ISODate ) );
82 _qt_timeEdit->blockSignals(
true);
83 _qt_timeEdit->setTime( QTime::fromString( fromUTF8( newValue ), Qt::ISODate ) );
84 _qt_timeEdit->blockSignals(
false);
90 _caption->
setText( fromUTF8( newLabel ) );
91 YTimeField::setLabel( newLabel );
97 QFrame::setEnabled( enabled );
98 YWidget::setEnabled( enabled );
104 return sizeHint().width();
110 return sizeHint().height();
116 resize( newWidth, newHeight );
122 _qt_timeEdit->setFocus();
128 void YQTimeField::changed (
const QTime& )
virtual std::string value()
Get the current value (the text entered by the user or set from the outside) of this input field.
virtual void setValue(const std::string &newValue)
Set the current value (the text entered by the user or set from the outside) of this input field.
virtual void setEnabled(bool enabled)
Set enabled/disabled state.
virtual int preferredHeight()
Preferred height of the widget.
virtual void setLabel(const std::string &label)
Set the label (the caption above the input field).
virtual bool setKeyboardFocus()
Accept the keyboard focus.
virtual ~YQTimeField()
Destructor.
YQTimeField(YWidget *parent, const std::string &label)
Constructor.
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
virtual int preferredWidth()
Preferred width of the widget.
static YQUI * ui()
Access the global Qt-UI.
void sendEvent(YEvent *event)
Widget event handlers (slots) call this when an event occured that should be the answer to a UserInpu...