Copy formatted text from line edit and paste in another line edit with same format
-
How to copy the formatted text from a line edit and paste the text with format in another line edit?
I try with following code.I can able to paste the text but not with format which I apply in the first line edit.
@
secondlineedit->insert(firstlineedit->text());
@ -
You can try with copy() and paste().. methods provided by the lineEdit.
-
How to copy the formatted text from a line edit and paste the text with format in another line edit?
I try with following code.I can able to paste the text but not with format which I apply in the first line edit.
@
secondlineedit->insert(firstlineedit->text());
@ -
@kshegunov
setHtml is the member for textedit not for line edit. -
@kshegunov
setHtml is the member for textedit not for line edit. -
@Bharathi
Sorry, my bad. But isn'tQLineEdit
for plain text? How do you have a formatted text in it?@Bharathi
@kshegunov said:How do you have a formatted text in it?
I am also curious about this. QLineEdit doesn't support rich-text/HTML-subset.
So about what formatting do you talk? -
@Bharathi
@kshegunov said:How do you have a formatted text in it?
I am also curious about this. QLineEdit doesn't support rich-text/HTML-subset.
So about what formatting do you talk?@raven-worx
intially I give text color in first line using setstylesheet as following code.
@
firstlinedit->setStyleSheet("color:red;"); -
@raven-worx
intially I give text color in first line using setstylesheet as following code.
@
firstlinedit->setStyleSheet("color:red;");@Bharathi
ok, you can't transfer this kind of formatting.
Since it's not part of the content itself, but only used for displaying by the widget (QLineEdit)QLineEdit's public API only support plain text. But internally it actually would support QTextFormats, etc.
Probably it's best if you create your custom widget (based on QTextEdit). Make sure to remove the scrollbar policies, filter the ENTER/RETURN key events and override the sizeHint to make it look like a one-liner text entry like the QLineEdit is.
-
I know the question is old. But I came across the same issue today. ( I'm using pyqt5 so my code will be in python.)
I solved it using the following logic:
for e.g. I have 2 qlineedits named lineedit1 and lineedit2 :
To keep the format same, in my case integers, I used setValidatorlineedit1.setValidator(QIntValidator())
lineedit2 .setValidator(QIntValidator())so to copy contents from lineedit1 to lineedit2, I used the following code:
linededit1.textChanged.connect(self.lineedit2.setText)
-
I know the question is old. But I came across the same issue today. ( I'm using pyqt5 so my code will be in python.)
I solved it using the following logic:
for e.g. I have 2 qlineedits named lineedit1 and lineedit2 :
To keep the format same, in my case integers, I used setValidatorlineedit1.setValidator(QIntValidator())
lineedit2 .setValidator(QIntValidator())so to copy contents from lineedit1 to lineedit2, I used the following code:
linededit1.textChanged.connect(self.lineedit2.setText)
@Shrey12
Hi and welcome to the forums.
Thank you for the input, however, it turned out that Poster wanted to copy a stylesheet
between LineEdits which is possible with any of the LineEdits functions.
So while your solution will copy the text in an elegant way, its
not really the original issues. :)