How to set validator for all Line edit
-
It is possible. What is possible is - Setting the validator is per object. You need to find the logic to set the validator for each&every lineEdit objects.
-
It is possible. What is possible is - Setting the validator is per object. You need to find the logic to set the validator for each&every lineEdit objects.
can we set the validator for a individual group instead of setting for each and every line edit.
Set Validator for all line edit in group which accepts only int values instead of setting for each and every line edit can we set validator for a all line edit at once so that it works.
Set Validator for all line edit in group which accepts only string values .
-
No nothing exist like this.
-
Hi,
You can use findChildren and use a loop to set the validator.
Also, you might want to consider using a more appropriate widget for integer input like QSpinBox.
-
Hi,
You can use findChildren and use a loop to set the validator.
Also, you might want to consider using a more appropriate widget for integer input like QSpinBox.
-
Hi,
You can use findChildren and use a loop to set the validator.
Also, you might want to consider using a more appropriate widget for integer input like QSpinBox.
-
Hi,
You can use findChildren and use a loop to set the validator.
Also, you might want to consider using a more appropriate widget for integer input like QSpinBox.
-
Yes, it possible if with little bit more programming. Set the object name for each of the lineEdit object. Inside the for loop just do something like.
for (int i=0; i < allPButtons.size(); i++) { if(allPButtons.at(i).objectName.compare("ManiRon")==0) { // set validator }else { allPButtons.at(i)->setValidator(new QIntValidator(0,20,this)); } }
-
Yes, it possible if with little bit more programming. Set the object name for each of the lineEdit object. Inside the for loop just do something like.
for (int i=0; i < allPButtons.size(); i++) { if(allPButtons.at(i).objectName.compare("ManiRon")==0) { // set validator }else { allPButtons.at(i)->setValidator(new QIntValidator(0,20,this)); } }
@dheerendra said in How to set validator for all Line edit:
if(allPButtons.at(i).objectName.compare("ManiRon")==0) {
// set validator
}elseit worked thanks sir
-
Cool. Enjoy Qt programming. Please move the issue to SOLVED state. It helps others as well.
-
One small thing:
@ManiRon said in How to set validator for all Line edit:QList<QLineEdit *> allPButtons
Be more careful with the names of your variables.
allPButtons
suggests a list of QPushButton which is unrelated to your QLineEdit setup. This makes your code hard to read and understand. -
One small thing:
@ManiRon said in How to set validator for all Line edit:QList<QLineEdit *> allPButtons
Be more careful with the names of your variables.
allPButtons
suggests a list of QPushButton which is unrelated to your QLineEdit setup. This makes your code hard to read and understand.