Skip to content

Commit

Permalink
Remove extra leading zeros
Browse files Browse the repository at this point in the history
  • Loading branch information
Admiral-Fish committed Oct 14, 2022
1 parent 6f086de commit 8abbcb3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Source/Forms/Controls/TextBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,17 @@ void TextBox::onTextEdited(QString string)
string = string.toUpper();
string.remove(filter);

// Remove any useless leading zeros
int count = 0;
while (string.size() > 1 && string[0] == '0')
{
string.remove(0, 1);
count++;
}

int position = this->cursorPosition();
this->setText(string);
this->setCursorPosition(position);
this->setCursorPosition(position - count);
}
}

Expand Down

0 comments on commit 8abbcb3

Please sign in to comment.