I want one example to set the validation for checkboxes?
I want one example to set the validation for checkboxes?
By validation if you mean to check whether the checkbox is checked or not use isChecked() method to find it out.
hi,
Qt Code:
class myClass:public .... { ........ ........ private: int nCnt; private slots: void chkClicked(int nState); }; connect(c1,SIGNAL(stateChanged(int)),this,SLOT(chkClicked(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--; } }To copy to clipboard, switch view to plain text mode
Use this nCnt to find the number checkboxes clicked.
hope it helps,
Bala
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
Last edited by sangee; 17th August 2012 at 13:01.
A QLineEdit *is not* a checkbox.
Why not? What isn't working? If you don't show us any code, we could guess forever about what is wrong.I used this code in my program.but it doesn't work .
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
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
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?
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.
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.
There is not standard way (known to me) to achieve this. You should write your own validator.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
Bookmarks