26 #define YUILogComponent "qt-ui"
27 #include <yui/YUILog.h>
29 #include <qdatetimeedit.h>
30 #include <QVBoxLayout>
34 #include "YQDateField.h"
35 #include "yui/YEvent.h"
36 #include "YQWidgetCaption.h"
42 : QFrame( (QWidget *) parent->widgetRep() )
43 , YDateField( parent, label )
45 QVBoxLayout* layout =
new QVBoxLayout(
this );
49 layout->setSpacing( YQWidgetSpacing );
50 layout->setMargin ( YQWidgetMargin );
53 YUI_CHECK_NEW( _caption );
54 layout->addWidget( _caption );
56 _qt_dateEdit =
new QDateEdit(
this );
57 YUI_CHECK_NEW( _qt_dateEdit );
58 layout->addWidget( _qt_dateEdit );
61 _qt_dateEdit->setDisplayFormat(
"yyyy-MM-dd" );
62 _qt_dateEdit->setCalendarPopup(
true);
63 _caption->setBuddy( _qt_dateEdit );
65 connect( _qt_dateEdit, &QDateEdit::dateChanged,
66 this, &YQDateField::changed);
78 return toUTF8( _qt_dateEdit->date().toString( Qt::ISODate ) );
84 _qt_dateEdit->blockSignals(
true);
85 _qt_dateEdit->setDate( QDate::fromString( fromUTF8( newValue ), Qt::ISODate ) );
86 _qt_dateEdit->blockSignals(
false);
92 _caption->
setText( fromUTF8( newLabel ) );
93 YDateField::setLabel( newLabel );
99 QFrame::setEnabled( enabled );
100 YWidget::setEnabled( enabled );
106 return sizeHint().width();
112 return sizeHint().height();
118 resize( newWidth, newHeight );
124 _qt_dateEdit->setFocus();
129 void YQDateField::changed (
const QDate& )
virtual bool setKeyboardFocus()
Accept the keyboard focus.
virtual void setEnabled(bool enabled)
Set enabled/disabled state.
virtual void setLabel(const std::string &label)
Set the label (the caption above the input field).
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 setSize(int newWidth, int newHeight)
Set the new size of the widget.
virtual int preferredHeight()
Preferred height of the widget.
YQDateField(YWidget *parent, const std::string &label)
Constructor.
virtual ~YQDateField()
Destructor.
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...