qtextbrowser update from different class
-
unable to update qt text browser from different class function.
Try's:
1.With qDebug function i can able to see my buffer content which i sent from other class, but updating to text browser wasn't happening.
2.I used append function to update to my textbrowser -
@Trojan-Arun
Show some code, including what you are trying to append to what.
It might be that usingQTextEdit::append()
is not going to work with the HTML you already have in yourQTextBrowser
. For example, if that already ends in</HTML>
, and you just append without chopping off, I don't know whether it will ignore the extra stuff you add. -
This is MainWindow Class function:
void MainWindow::print_in_text(QString temp)
{
qDebug()<<temp;
QString print_buffer = temp;
qDebug()<<print_buffer;
ui->textBrowser->append(print_buffer);
}This is EmitterTest Class
void emittertest::text_function()
{
MainWindow *text;
qDebug()<<"in text_function";
QString buf="hello";
text->print_in_text(buf);
}Calling MainWindow class Function from EmitterTest Class function.
-
void emittertest::text_function()
{
MainWindow text;
qDebug()<<"in text_function";
QString buf="hello";
text.print_in_text("buf");
}i even tried in this way... But textbrowser not appending buf content
-
@Trojan-Arun said in qtextbrowser update from different class:
But textbrowser not appending buf content
How do you know? I mean, you do not show the main window.
And now your text only exists inside text_function() - each time you call this method you create new main window... -
Sorry in my previous call i did that..
here it is..Trojan Arun about 17 hours ago
This is MainWindow Class function:
void MainWindow::print_in_text(QString temp)
{
qDebug()<<temp;
QString print_buffer = temp;
qDebug()<<print_buffer;
ui->textBrowser->append(print_buffer);
}EmitterTest class
void emittertest::text_function()
{
MainWindow text;
qDebug()<<"in text_function";
QString buf="hello";
text.print_in_text("buf");
} -
@Trojan-Arun I know. But this does not answer my question.
So, again: how do you know this "But textbrowser not appending buf content"?void emittertest::text_function() { MainWindow text; // This is local variable, each time you call text_function() you // create new text and append to it and not to the previous one qDebug()<<"in text_function"; QString buf="hello"; text.print_in_text("buf"); }
-
So, again: how do you know this "But textbrowser not appending buf content"?
- with the help of debug prints i m able to see my buf content in print_in_text mainwindow function.
-
@Trojan-Arun I already explained you that you are creating a LOCAL variable "text". Are you aware of that? Make "MainWindow text" member variable in your emittertest class...