QPlainText: not update after append text
-
I create a console window using
QPlainTextEditused to display my application status.It was created inside the
app.ui.
So, if I useappendPlainText()orappendHtml()from any method inside myAppClass, it works good!But now, I have another class (*.ui) that need to send a message to the
AppClass and shows it on myQPlainTextEditconsole.So I send a signal from my
anotherClasswith some text, like:class AnotherClass { ... signals: sendMsg(QString msg); }class AppClass { .... slots: receiveMsg(QString msg); }AppClass::receiveMsg(QString msg) { // Append text Ok, but not refresh QPlainTextEdit. // It only shows the appended text when I manually scroll the QPlainTextEdit // Not auto "refresh" and not "auto scroll" to the bottom ui->qplaintextedit->appendPlainText(msg); // I ALREADY TRIED: // A) // int v = ui->qplaintextedit->verticalScrollBar()->maximum(); // ui->qplaintextedit->verticalScrollBar()->setValue(v); // B) // ui->qplaintextedit->setCenterOnScroll(true); // ui->qplaintextedit->centerCursor(); // C) // ui->qplaintextedit->show(); }In this case (
signalandslot) how can I auto refresh and scroll theQPlainTextEditto the bottom? -
-
Hi,
What does that other class do ?
Does it do any heaving computation ? -
@SGaist at this time...no.
TheAnotherClassis simple...I just want to send a msg fromAnotherClasstoAppClassand see it on theQPlainTextconsole with auto refresh and scroll to the bottom line.In the future, may be, I will implemente other classes that will have some heavy computation power.
Could you help me?
-
@fem_dev said in QPlainText: not update after append text:
Any ideas?
What OS do you have? Did you also search the Qt bug tracker?
Please provide a minimal example so we can test it locally. -
@fem_dev said in QPlainText: not update after append text:
Any ideas?
What OS do you have? Did you also search the Qt bug tracker?
Please provide a minimal example so we can test it locally.@Christian-Ehrlicher
I copied my Qt project from a Mac OSX Catalina machine to another computer that is running Ubuntu 20.04.When I run it on Ubuntu, it works perfect! No issues.
It automatically "refresh" and scroll to the bottom line.
A simple example:
AnotherClass::AnotherClass() { emit sendMsg("This is a msg from anotherClass"); }AppClass::receiveMsg(QString msg) { ui->qplaintextedit->appendPlainText(msg); }May be this problem is just in OSX Catalina....I don't know...
Important: Both OSX Catalina and Ubuntu 20.04 machines are running:
- Qt Creator 4.12.3
- Qt 5.15
Please, tell me if you need more details...
-
Emitting a signal in a constructor is a bad idea as you can't have connected it to a slot at that point in time.
-
Emitting a signal in a constructor is a bad idea as you can't have connected it to a slot at that point in time.
@SGaist sorry....
I just put the
emitin the constructor only in this simple example, but int my real code thisemitis outside the class constructor...I did it here just to explain my question.
The key point is that:
ThereceiveMsg()was triggered and I got theQString msgwith success.
I think that themsgis already appended to myqplaintextedit, but this widget IS NOT SHOWING automatically the appendedmsg. May be theQPlainTextEditUI is not rendering as it should be.So, after that, if I MANUALLY scroll the
QPlainTextEditvertically up and down, this widget "refresh" and shows the appendedmsgat the bottom line.Any ideas?
May be this problem is just in OSX Catalina....I don't know...
Important: Both OSX Catalina and Ubuntu 20.04 machines are running:
- Qt Creator 4.12.3
- Qt 5.15
-
Since it seems to be easy to reproduce I would create a testcase and open a bug report.
-
Since it seems to be easy to reproduce I would create a testcase and open a bug report.
@Christian-Ehrlicher It's my first time reporting a possible bug...
Where should I report it? Do you have a link?
-