PDA

View Full Version : QTextBlock::setVisible()



jgrauman
23rd June 2009, 21:25
Hello,

Does anyone know how QTextBlock::setVisible() works? I thought I should be able to iterate down blocks of my document and hide blocks like following, but this does nothing as far as I can see...



QTextBlock blk = document()->begin();
blk = blk.next();
blk = blk.next();
blk = blk.next();
blk.setVisible(0);

shentian
24th June 2009, 10:16
Your conde only hides the fourth block in your document (if there are less than four text blocks, it will do nothing). If you want to hide all blocks, do the following:



QTextBlock blk = document()->begin();
while (blk.isValid())
{
blk.setVisible(false);
blk = blk.next();
}

jgrauman
24th June 2009, 19:20
Exactly! On my QTextEdit, my code doesn't hide the fourth block, and your code doesn't hide any blocks. I would have thought your code would hide all my blocks as well, but nothing seems to be happening. Any thoughts why this could be?

JohannesMunk
11th December 2009, 02:06
I'm having trouble with this as well!

QTextBlock.setVisible doesn't work apparently!

Or is the above usage pattern wrong?

Thx in advance!

Johannes