Hi!
Have you tried to show() the QTextEdit BEFORE the setVisible() on his QTextBlock?
Hi!
Have you tried to show() the QTextEdit BEFORE the setVisible() on his QTextBlock?
Hi! Thanks for your reply!
I'm using this code actually to implement a filter, if a block contains a certain word. As the user configures the filter, the QTextEdit is visible way before. Only in this small example its the other way around.
Any further ideas?
Johannes
Ok, this is a small piece of code to "Fold" a certain piece of document in my Code editor.
As you can see I call a setVisible( false ) to the QTextBlock.
Qt Code:
while( thblock.isValid() && !thblock.isVisible() ){ thblock.setVisible( true ); thblock = thblock.next(); } if( dynamic_cast<CMagnum_TextBlock*>(thblock.userData()) != 0 ){ CMagnum_TextBlock* mudata = dynamic_cast<CMagnum_TextBlock*>(thblock.userData()); while( thblock.isValid() && thblock.blockNumber() < mudata->foldable() && mudata->foldable() != -1 ){ thblock.setVisible( false ); thblock = thblock.next(); } } editor->viewport()->update(); editor->lineNumberArea->update(); editor->m_foldArea->update(); }To copy to clipboard, switch view to plain text mode
... at the end I have added editor->viewport->update().
Keep in mind that "editor" is a QPlainTextEdit and viewport() return his QAbstractScrollArea.
Maybe an update can help you![]()
JohannesMunk (19th February 2010)
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?
Qt Code:
#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(); }To copy to clipboard, switch view to plain text mode
Thx for your time!
Johannes
Happy to be useful
But i'll advise you, In my code editor i have a strange error with setVisibile():when i hide a lot of block, seem that the Vertical scroolbar "scroll" the hide blocks too!
If you find a solution please keep me updated!
Thx
Claudio
Bookmarks