28 #define YUILogComponent "qt-ui" 29 #include <yui/YUILog.h> 33 #include <yui/YEvent.h> 34 #include "YQIntField.h" 35 #include "YQSignalBlocker.h" 36 #include "YQWidgetCaption.h" 37 #include <QVBoxLayout> 40 const std::string & label,
44 : QFrame( (QWidget *) parent->widgetRep() )
45 , YIntField( parent, label, minValue, maxValue )
47 QVBoxLayout* layout =
new QVBoxLayout(
this );
52 layout->setSpacing( YQWidgetSpacing );
53 layout->setMargin( YQWidgetMargin );
56 YUI_CHECK_NEW( _caption );
57 layout->addWidget( _caption );
59 _qt_spinBox =
new QSpinBox(
this);
60 _qt_spinBox->setMinimum(minValue);
61 _qt_spinBox->setMaximum(maxValue);
62 _qt_spinBox->setSingleStep(1);
64 YUI_CHECK_NEW( _qt_spinBox );
65 layout->addWidget( _qt_spinBox );
67 _qt_spinBox->setValue( initialValue );
69 _caption->setBuddy( _qt_spinBox );
71 setValue( initialValue );
73 connect( _qt_spinBox,
static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
87 return _qt_spinBox->value();
95 _qt_spinBox->setValue( newValue );
111 YIntField::setLabel( newLabel );
119 _caption->setEnabled ( enabled );
120 _qt_spinBox->setEnabled( enabled );
121 YWidget::setEnabled( enabled );
128 return sizeHint().width();
135 return sizeHint().height();
142 resize( newWidth, newHeight );
149 _qt_spinBox->setFocus();
155 #include "YQIntField.moc" Helper class to block Qt signals for QWidgets or QObjects as long as this object exists.
virtual bool setKeyboardFocus()
Accept the keyboard focus.
virtual void setValueInternal(int val)
Set the current value (the number entered by the user or set from the outside) of this IntField...
virtual int value()
Get the current value (the number entered by the user or set from the outside) of this IntField...
void sendEvent(YEvent *event)
Widget event handlers (slots) call this when an event occured that should be the answer to a UserInpu...
virtual void setEnabled(bool enabled)
Sets the widget's enabled state.
void valueChanged(int newValue)
Emitted when the value changes (regardless of the notify flag).
void valueChangedSlot(int newValue)
Slot for "value changed".
virtual ~YQIntField()
Destructor.
virtual void setLabel(const std::string &label)
Set the label (the caption above the input field).
virtual int preferredHeight()
Preferred height of the widget.
YQIntField(YWidget *parent, const std::string &label, int minValue, int maxValue, int initialValue)
Constructor.
virtual int preferredWidth()
Preferred width of the widget.
static YQUI * ui()
Access the global Qt-UI.
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.