line edit
-
Do you want to separate by dots ? or value ? i don't get this
-
Do you want to separate by dots ? or value ? i don't get this
@Emre-MUTLU
I want only one point to be entered
I want it to give an error even though more than one point is entered -
There are better ways but this came to mind.
QString str=ui->lineEdit->Text(); QStringList list; for(int i=0;i<ui->lineEdit->Text().Length();i++) { list=str.split("."); } if(list.Length()>2) { qDebug()<<" more than one point is entered"; } -
Hi,
Why not use a QDoubleSpinBox for your number input ?
-
Hi,
Why not use a QDoubleSpinBox for your number input ?
@SGaist
can you give an example -
@SGaist
can you give an example@muhammed-hayr If you open the link @SGaist gave you you will find a link "Spin Boxes Example"...
-
@muhammed-hayr If you open the link @SGaist gave you you will find a link "Spin Boxes Example"...
@jsulm
I am using numpad -
@jsulm
I am using numpad -
There are better ways but this came to mind.
QString str=ui->lineEdit->Text(); QStringList list; for(int i=0;i<ui->lineEdit->Text().Length();i++) { list=str.split("."); } if(list.Length()>2) { qDebug()<<" more than one point is entered"; }@Emre-MUTLU Why the loop?
Shorter version:
QString text = myLineEdit.text(); if (2 < text.split('.', Qt::KeepEmptyParts).length()) // Display your warningThe cleaner way would be a RegEx validator in my opinion. Although this here should work and would be way less effort, haha.
-
There are better ways but this came to mind.
QString str=ui->lineEdit->Text(); QStringList list; for(int i=0;i<ui->lineEdit->Text().Length();i++) { list=str.split("."); } if(list.Length()>2) { qDebug()<<" more than one point is entered"; }@Emre-MUTLU said in line edit:
There are better ways but this came to mind.
?