Unsolved Print to screen from qDebug
-
QProcess process;
process.start("sudo devmem2 0x80000000");
process.waitForFinished(-1); // will wait forever until finishedQString stdout = process.readAllStandardOutput();
QString stderr = process.readAllStandardError();qDebug() << stdout; ui->lineEdit->setText(qDebug());
I want to display my qDebug to lineEdit in Qt.
-
@Mijaz
Yourstdout
is just aQString
. So whyqDebug()
? You just needui->lineEdit->setText(stdout);
. -
Hi @JonB Thanks, it works...
Can I define range like this?
ui->lineEdit->setText(stdout[90:105]); -
@Mijaz
Where doesQString
(or C++) define a[start:end]
"range operator"? Since it does not (you're not in Python!), no you cannot do that. Read the docs forQString
, e.g. https://doc.qt.io/qt-5/qstring.html#mid. -
@JonB not yet, but there's an awful amount of talking about it for c++20 ....
-
@J-Hilk
Just great. C was fine, let's make C++ more like hideous Python... ;-) -
@JonB well, that's one way of looking at it, I think its nice, that after 35 Years, the user base still grows and the language still adapts new features :)
look at this beauty and tell me its hideous :P
int main() { std::vector<int> ints{0,1,2,3,4,5}; auto even = [](int i){ return 0 == i % 2; }; auto square = [](int i) { return i * i; }; for (int i : ints | std::views::filter(even) | std::views::transform(square)) { std::cout << i << ' '; } } //Output: 0 4 16
-
@J-Hilk
This is probably not the place for a discussion, but yes I think it's hard to read/understand. WTF is that|
logical-or operator doing in thefor
against arrays? (Yes, I can guess...) Is it really easier to read or more efficient than anif
inside the loop? Depending on how thatfor ( ... | ...)
is implemented, it could be hideously inefficient!