1 #include "QDS_CheckBox.h"
6 Constructor. This method is protected. Object can't be directly constructed.
7 Use static method QDS_CheckBox::Create instead.
9 QDS_CheckBox::QDS_CheckBox( const QString& id, QWidget* parent, const int flags, const QString& comp )
10 : QDS_Datum( id, parent, flags, comp )
17 QDS_CheckBox::~QDS_CheckBox()
22 Sets the state "NoChange" for checkbox.
24 void QDS_CheckBox::clear()
26 setStringValue( "-1" );
30 Returns string from QCheckBox widget.
32 QString QDS_CheckBox::getString() const
35 if ( checkBox() && checkBox()->state() != QButton::NoChange )
36 val = checkBox()->isChecked() ? "1" : "0";
41 Sets the string into QCheckBox widget.
43 void QDS_CheckBox::setString( const QString& txt )
49 int val = (int)txt.toDouble( &isOk );
50 if ( isOk && val < 0 )
52 checkBox()->setTristate();
53 checkBox()->setNoChange();
56 checkBox()->setChecked( isOk && val != 0 );
60 Returns pointer to QCheckBox widget.
62 QCheckBox* QDS_CheckBox::checkBox() const
64 return ::qt_cast<QCheckBox*>( controlWidget() );
68 Create QCheckBox widget as control subwidget.
70 QWidget* QDS_CheckBox::createControl( QWidget* parent )
72 QCheckBox* cb = new QCheckBox( parent );
73 connect( cb, SIGNAL( stateChanged( int ) ), SLOT( onParamChanged() ) );
74 connect( cb, SIGNAL( toggled( bool ) ), SIGNAL( toggled( bool ) ) );
75 connect( cb, SIGNAL( stateChanged( int ) ), this, SLOT( onStateChanged( int ) ) );
80 Notify about shanging of control state
82 void QDS_CheckBox::onParamChanged()
87 void QDS_CheckBox::onStateChanged( int state )
89 if ( state != QButton::NoChange && checkBox() )
90 checkBox()->setTristate( false );
93 void QDS_CheckBox::setChecked( const bool theState )
96 checkBox()->setChecked( theState );
99 bool QDS_CheckBox::isChecked() const
101 return checkBox() ? checkBox()->isChecked() : false;