QlineEdit with constant text and editable text fields
-
Thanks a lot for the example.
But this solution using QLabel & QLineEdit will not suit my usecase.
The content text of this LineEdit will be used as file name after replacing placeholder <COUNTER> with values from 0..N. -
@Embitel_qt
Hi can I ask what is wrong with it ?
Just to understand.
It would be easy to create function to return a QString containing
edit + Label text. -
This above mentioned is only one use case. The actual functionality of my LineEdit will contain multiple placeholder fields like <DATE>, <TIME>, etc... which can be added to the LineEdit on the current cursor position.
So its not an option to use combination of QLineEdit & QLabel.
-
@Embitel_qt Will hiding the "<COUNTER>" piece of text in the code and having only a LineEdit be satisfactory? I mean storing QLineEdit as a string and adding <COUNTER> to it in code.
-
@Embitel_qt
ah, so <X> can appear anywhere in the text
and after insertion, should not be editable?
So you need to support all cases of
<X>aaaaa
aaaa<X>aaaa
aaaa<X> -
@mrjj yes you are correct <X> can be added at any position in one usecase.
In my first use case [mode one] there will be only <COUNTER> and this should be always at the end of the LineEdit and which should not be edited. But the user can insert new characters before <COUNTER>
In my second use case[mode two] there can be any place holder[<CONTER>, <DATE>, <TIME>, etc...] all this can be editable[no restrictions] and user can insert new characters anywhere in the LineEdit.
-
lineEdit->setInputMask("Im\\age\\_0000");
-
Thnaks for the inputs.
Now I have found a way to make my <COUNTER> non editable using the masklineEdit->setInputMask("xxxx\<\C\O\U\N\T\E\R\>");
Now thw problem is I am able to enter only 4 characters before <COUNTER> but i want to allow the user to enter maximum of 91 charcters.
What should I modify on the reg expression to achieve this?
-
@Embitel_qt Could you not just use 91 "x"s?
lineEdit->setInputMask("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1<\C\O\U\N\T\E\R>");
-
might be slightly more compact to use the fill method. :)