[solved] return a qstring of a line by lineposition of a plaintextedit
-
I return to "+=".
Now I try to put from begin in this forum code:
if (i!=lines.size()-1)
plainTextEditContents += "\n";but I don't know which python function is equivalent for C++'s .size()
-
First, I already showed you that
"\n".join(lines)
does the whole of what thefor
loop does, without any need to build it line by line or look at how may elements are inlines
. Now you return to not using it. -
If you insist on doing it your slow way, look up what C++ QList::size() returns and then use your knowledge of Python to call its method for returning the number of items in a Python
list
.
Sorry, but you are making a mountain out of mole hill for this and not acting properly on suggestions. I leave you to it....
-
-
I return to "+=".
Now I try to put from begin in this forum code:
if (i!=lines.size()-1)
plainTextEditContents += "\n";but I don't know which python function is equivalent for C++'s .size()
@Karoluss96 Please take a look at the code you posted and think about what you are doing:
plainText = "\n".join(a) for i in a: plainText += i
Don't you think that you're doing same thing two times?
-
Yes It true :-D , but I still I don't know how to put every line from sql question into text Edit, like I show in one of posts above
-
Yes It true :-D , but I still I don't know how to put every line from sql question into text Edit, like I show in one of posts above
@Karoluss96 Do you mean this:
self.dlg.plainTextEdit.setPlaceholderText(plainText)
? If so it should work already. Or do you want to set normal text (not placeholder)?
-
I changed plaintextEdit to textEdit, but setplaceholder is the same.
plainText must be a string or list string?
-
I changed plaintextEdit to textEdit, but setplaceholder is the same.
plainText must be a string or list string?
@Karoluss96 Why don't you simply read the documentation?!
https://doc.qt.io/qt-6/qtextedit.html#setText
https://doc.qt.io/qt-6/qtextedit.html#setPlainText
https://doc.qt.io/qt-6/qtextedit.html#placeholderText-prop -
I changed plaintextEdit to textEdit, but setplaceholder is the same.
plainText must be a string or list string?
@Karoluss96
What is going on here? Did you read whatsetPlaceHolder()
does? It will only show anything if the text edit is empty. Is it? Is that what you really want anyway?As @jsulm & I say, why don't you try reading the documentation and make the appropriate calls, rather than guessing and asking about each thing?
-
@Karoluss96 Why don't you simply read the documentation?!
https://doc.qt.io/qt-6/qtextedit.html#setText
https://doc.qt.io/qt-6/qtextedit.html#setPlainText
https://doc.qt.io/qt-6/qtextedit.html#placeholderText-prop@jsulm Thank I've already read it
-
@jsulm Thank I've already read it
@Karoluss96 said in [solved] return a qstring of a line by lineposition of a plaintextedit:
Thank I've already read it
OK, and what is the problem?
-
In Text Edit I want to see eg.:
'wait - waiting for data
protocol - data in protocol
end_of_contr - the end of control 'each record from sql query must be in new line separatly
not only last line (in example: 'end_of_contr - the end of control ')
-
In Text Edit I want to see eg.:
'wait - waiting for data
protocol - data in protocol
end_of_contr - the end of control 'each record from sql query must be in new line separatly
not only last line (in example: 'end_of_contr - the end of control ')
This post is deleted! -
In Text Edit I want to see eg.:
'wait - waiting for data
protocol - data in protocol
end_of_contr - the end of control 'each record from sql query must be in new line separatly
not only last line (in example: 'end_of_contr - the end of control ')
@Karoluss96 said in [solved] return a qstring of a line by lineposition of a plaintextedit:
not only last line (in example: 'end_of_contr - the end of control ')
Then what does plainText contain before you add it to the text edit? And what does a contain? Did you do any debugging to find out why only last line is added?
Hint: if you call setText() it REPLACES what was added before...
-
In Text Edit I want to see eg.:
'wait - waiting for data
protocol - data in protocol
end_of_contr - the end of control 'each record from sql query must be in new line separatly
not only last line (in example: 'end_of_contr - the end of control ')
@Karoluss96
Have already answered this several times above. Meanwhile, do you really intend to usesetPlaceholderText()
for what you want? Or do you intend to not answer? -
@Karoluss96 said in [solved] return a qstring of a line by lineposition of a plaintextedit:
not only last line (in example: 'end_of_contr - the end of control ')
Then what does plainText contain before you add it to the text edit? And what does a contain? Did you do any debugging to find out why only last line is added?
Hint: if you call setText() it REPLACES what was added before...
@jsulm said in [solved] return a qstring of a line by lineposition of a plaintextedit:
Then what does plainText contain before you add it to the text edit? And what does a contain? Did you do any debugging to find out why only last line is added?
Hint: if you call setText() it REPLACES what was added before...I debuged by print(). Console present all options good, in lines one by one. I removed placeHolderText for setText but as the documentation (and you) says it also replace the lines one-by-one, wheras I need that all lines must stay in textEdit
-
@jsulm said in [solved] return a qstring of a line by lineposition of a plaintextedit:
Then what does plainText contain before you add it to the text edit? And what does a contain? Did you do any debugging to find out why only last line is added?
Hint: if you call setText() it REPLACES what was added before...I debuged by print(). Console present all options good, in lines one by one. I removed placeHolderText for setText but as the documentation (and you) says it also replace the lines one-by-one, wheras I need that all lines must stay in textEdit
@Karoluss96 If you want to keep what is already there then why don't you simply do
self.dlg.plainTextEdit.setText(self.dlg.plainTextEdit.text() + plainText)
-
@Karoluss96 If you want to keep what is already there then why don't you simply do
self.dlg.plainTextEdit.setText(self.dlg.plainTextEdit.text() + plainText)
@jsulm , @Karoluss96
Who knows what the OP actually wants?! But even simpler for that would beself.dlg.plainTextEdit.appendPlainText(plainText)
(It might put in an extra
\n
before the new text, because it talks about "Appends a new paragraph with text to the end of the text edit.", not sure.) -
-
@Karoluss96 It was your roommate's fault ;-)
-
Ha, ha, ha @JonB :-D