PDA

View Full Version : set the validation for checkboxes



sangee
14th August 2012, 07:46
I want one example to set the validation for checkboxes?

Charvi
14th August 2012, 07:54
By validation if you mean to check whether the checkbox is checked or not use isChecked() method to find it out.

BalaQT
17th August 2012, 07:37
hi,




class myClass:public ....
{
........
........
private:
int nCnt;
private slots:
void chkClicked(int nState);
};
QCheckBox *c1 = new QCheckBox;
connect(c1,SIGNAL(stateChanged(int)),this,SLOT(chk Clicked(int)));

//Constructor
myClass::myClass()
{
....
....
nCnt = 0;
....
....
}

void myClass::chkClicked(int nState)
{
if( nState == Qt::Checked)
{
nCnt++;
//Check box checked
}
else if( nState == Qt::Unchecked)
{
//Check box unchecked
nCnt--;
}
}


Use this nCnt to find the number checkboxes clicked.

hope it helps,
Bala

sangee
17th August 2012, 12:42
I used this code in my program.but it doesn't work .

QDoubleValidator *validator=new QDoubleValidator(18.5,39.0,1,m_ui->lineEdit);
m_ui->lineEdit->setValidator(validator);

I want to set the validation for LineEdit .plz reply me

d_stranz
17th August 2012, 17:25
A QLineEdit *is not* a checkbox.


I used this code in my program.but it doesn't work .


Why not? What isn't working? If you don't show us any code, we could guess forever about what is wrong.

sangee
22nd August 2012, 12:18
I used this code in my program.but it doesn't work .

QDoubleValidator *validator=new QDoubleValidator(18.5,39.0,1,m_ui->lineEdit);
m_ui->lineEdit->setValidator(validator);

I want to set the validation for LineEdit .plz reply me

Naahmi
22nd August 2012, 18:14
I used this code in my program.but it doesn't work .

QDoubleValidator *validator=new QDoubleValidator(18.5,39.0,1,m_ui->lineEdit);
m_ui->lineEdit->setValidator(validator);

I want to set the validation for LineEdit .plz reply me

and WHAT is your problem?

sangee
24th August 2012, 08:09
I used keyboard design in my program.I want to set the values 18.5 to 39.0 only for keyboard's LineEdit.how to set the validation for this LineEdit?

ChrisW67
24th August 2012, 08:15
We don't want to know what you are trying to do; that is evident from the correct code you posted. We want to know why you think it is "not working" and how you determined that.

sangee
24th August 2012, 08:55
QDoubleValidator consider for decimal points only not range(18.5 to 39.0).how i set the validation for this LineEdit? I want one example for LineEdit Validation.

spirit
24th August 2012, 09:45
There is not standard way (known to me) to achieve this. You should write your own validator.