Aah! With QPlainTextEdit it works! No update required. Doesn't matter where show is called.
Is block.setVisible(false) supposed to not work with QTextEdit?
#include <QtGui/QApplication>
#include <QtGui>
int main(int argc, char *argv[])
{
QPlainTextEdit* te = new QPlainTextEdit();
te->setPlainText("Great [Debug]\nThis is an Error![Error]\nGreat [Debug]\n");
while (blk.isValid())
{
bool cond = true;
if (blk.text().contains("Debug"))
{
cond = false;
qDebug() << "Setting block invisible";
}
blk.setVisible(cond);
blk = blk.next();
}
te->show();
//te->document()->markContentsDirty(0,te->document()->end().position());
//te->viewport()->update();
return a.exec();
}
#include <QtGui/QApplication>
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPlainTextEdit* te = new QPlainTextEdit();
te->setPlainText("Great [Debug]\nThis is an Error![Error]\nGreat [Debug]\n");
QTextBlock blk = te->document()->firstBlock();
while (blk.isValid())
{
bool cond = true;
if (blk.text().contains("Debug"))
{
cond = false;
qDebug() << "Setting block invisible";
}
blk.setVisible(cond);
blk = blk.next();
}
te->show();
//te->document()->markContentsDirty(0,te->document()->end().position());
//te->viewport()->update();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Thx for your time!
Johannes
Bookmarks