QString appendText,,,,
-
As always , I am not sure where to post this .
I am not sure how exactly this snippet works...the syntax is unfamiliar
But it gives a local result (QEditText) when it runs "class variable " QProcess - proc.What I need is to have "appendText" as common , class variable, so it can
be reused by other class .QString appendText(proc->readAll()); // slot ???
ui->textEdit_3->append(appendText); // just display all - works fine -
Hi
When you say "common , class variable, so it can
be reused by other class ."Do you mean many instances of the same class SHARE this text or that these classes can ask some class about it and its sort of the text holder ?
-
@mrjj Whna I met was - the QString variable "appendText" is local to the function. .
I like to have it as class variable / member .Actually I like to know /have explanation about the syntax
- to me it looks as "function call of function appendText
It is not that important, I found a workaround to do same - return a text / QStiing .
Thanks -
@AnneRanch said in QString appendText,,,,:
Actually I like to know /have explanation about the syntax
to me it looks as "function call of function appendTe
QString appendText(proc->readAll());
Yes In C this would not be allowed. In C++ when declaring a class (
QString
here) variable we can create/initialize it with a value, in parentheses (among other ways). This actually uses the constructor at https://doc.qt.io/qt-6/qstring.html#QString-9, you could use any of the others (there are 10 of them!) listed there. That's why it's( ... )
: It calls yourproc->readAll()
and sets the variable to that.