add QLabel into QLineEdit
-
@marlenet15
and the label should be sort of inside the lineEdit ?
something like
Jan 20 2016:____________
where ________ is the linedit is not ok?@mrjj Yes. I would like for the QLabel to be inside the QLineEdit. So I would like it to look like this
Comments(QLabel) (Jan 19 2016: ____________________________ ) <- inside paranthesis is the QLineEdit and the __ is the part where the user can type
-
Well , it will be messy as the cursor might go into/under label
so not so easy to match up.
The same you linked to is postfix so if we limit the length
then it wont go into. but in ur case it will. -
Well , it will be messy as the cursor might go into/under label
so not so easy to match up.
The same you linked to is postfix so if we limit the length
then it wont go into. but in ur case it will.@mrjj is it even plausible to make the timestamp uneditable text and the rest can be editable. That way I don't add a QLabel inside the QLineEdit?
-
@mrjj is it even plausible to make the timestamp uneditable text and the rest can be editable. That way I don't add a QLabel inside the QLineEdit?
@marlenet15
well maybe u can make inputmask do something like that.Best solution would be custom widget but that is far more work.
Not even sure how to make it overlap. -
@marlenet15
well maybe u can make inputmask do something like that.Best solution would be custom widget but that is far more work.
Not even sure how to make it overlap.@mrjj Do you have an idea how to make it work with an input mask?
-
@mrjj Do you have an idea how to make it work with an input mask?
@marlenet15
yes using escape
\D\A\T\E:AAAAA-AAAAA-AAAAA-AAAAA-AAAAA
it shows as "Date:" and u cant change it.
so should be able to show an actual date. -
@marlenet15
yes using escape
\D\A\T\E:AAAAA-AAAAA-AAAAA-AAAAA-AAAAA
it shows as "Date:" and u cant change it.
so should be able to show an actual date.@mrjj So the actual text "Date:" can be changed to "Jan 19 2016" or any format of date?
-
@mrjj So the actual text "Date:" can be changed to "Jan 19 2016" or any format of date?
@marlenet15
yes
its not pretty but
\J\a\n\ \1\9\ \2\0\1\6:AAAAAAdoes look correct.
-
@marlenet15
yes
its not pretty but
\J\a\n\ \1\9\ \2\0\1\6:AAAAAAdoes look correct.
i also think the input mask is actually the best way, or maybe even better a custom QValidator.
But to just add something to the (rather ugly) QLabel idea: You could use QLineEdit::setTextMargins() to move the left-most position of the cursor. -
@marlenet15
yes
its not pretty but
\J\a\n\ \1\9\ \2\0\1\6:AAAAAAdoes look correct.
@mrjj So right now in my code the date that is going into the QLineedit is the current date. So I would need to separate the string and make sure to add \ ? Also what do the A's mean? the ones you put in your example?
-
i also think the input mask is actually the best way, or maybe even better a custom QValidator.
But to just add something to the (rather ugly) QLabel idea: You could use QLineEdit::setTextMargins() to move the left-most position of the cursor.@raven-worx yes I agree the input mask Is the best way to go. However, it's a new concept for me since I never heard of it. That is why I am very confused to how it works.
-
@raven-worx yes I agree the input mask Is the best way to go. However, it's a new concept for me since I never heard of it. That is why I am very confused to how it works.
@raven-worx said:
setTextMargins
+1 That would work for custom control.yes, you would need to put \ into your date.
the AAAA is input specifier .
Go to a LineEdit and find inputmask property and press F1 to read about them. -
@raven-worx said:
setTextMargins
+1 That would work for custom control.yes, you would need to put \ into your date.
the AAAA is input specifier .
Go to a LineEdit and find inputmask property and press F1 to read about them.@mrjj So if the user is allowed 100 characters for the QLineEdit do I have to put 100 A's?
-
@mrjj So if the user is allowed 100 characters for the QLineEdit do I have to put 100 A's?
@marlenet15 erhm, yes I think. maybe there is way
but inputmasks are normally used for short input like date
or iP etc -
@mrjj So if the user is allowed 100 characters for the QLineEdit do I have to put 100 A's?
@marlenet15
if you are familiar with regular expressions you might want to use QRegExpValidator which will result in the same behavior
And set it on the line edit. -
@marlenet15
if you are familiar with regular expressions you might want to use QRegExpValidator which will result in the same behavior
And set it on the line edit.@raven-worx
oh. So QRegExpValidator can have static text? -
@raven-worx
oh. So QRegExpValidator can have static text?@mrjj
Of course, a regular expression can have a static text included -
@mrjj
Of course, a regular expression can have a static text included@raven-worx
yes, but i didn't know it would show in lineEdit as Validator sounds so none visual :) -
@mrjj
Of course, a regular expression can have a static text included@raven-worx Can you please show me an example of that? I have never heard of that and I googled it and I didn't find anything about that :)
-
@raven-worx Can you please show me an example of that? I have never heard of that and I googled it and I didn't find anything about that :)
@marlenet15
you can see how to use QRegExpValidator in the link i've posted.
Use a RegExp similiar to this one. There are tons of material on the web about regexp to learn.QRegExp("Comments\\: ([Jan|Feb|Mar|Apr|Jun|Jul|Aug|Sep|Nov|Dec] [0-3]?[0-9] [0-9]{4}\\: (.+))");
This regexp is surely not perfect, but enough to get an idea and continue to learn the syntax i guess.