I have read some posts but none of them apply to what I want to do. I need a QLineEdit
that will edit a vector of numbers (let's say a vector of 3 doubles). I want to represent my vector in parenthesis in the QLineEdit
and separate the vector elements with a comma. So if the QLineEdit
is set to edit a vector of 5 elements, its contents should be like this - (1, 2, 3, 4, 5). The user should be able to edit the numbers, but obviously not be able to touch either the parenthesis or the commas, since they are separators.
What is the best way to achieve this? One thing that's coming to my mind is have as many QLineEdits
as there are elements in the vector, but make it appear to the user as if it's one QLineEdit.
Insert the commas in between in a QLineEdit
control that is read-only. Same can be done with the parenthesis.
Do you think it's the best way or there's a better approach?
Thank you!
Here's a screenshot of what I want it to look like. I want the user to be able to edit the numbers only, but not the commas or the parenthesis.
P.S. I just realized that my offered solution will take a lot of time to implement and it has a lot of edge cases. Because I have to allocate certain space for each QLineEdit
and then becomes numbers can be longer they have to be resized, same when the numbers get shorter.
Was going through the QLineEdit
document and saw the inputMask
property. It looks like it is exactly what I need: