Results 1 to 4 of 4

Thread: QTextBlock::setVisible()

  1. #1
    Join Date
    Nov 2007
    Posts
    16
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTextBlock::setVisible()

    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...

    Qt Code:
    1. QTextBlock blk = document()->begin();
    2. blk = blk.next();
    3. blk = blk.next();
    4. blk = blk.next();
    5. blk.setVisible(0);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    May 2009
    Posts
    62
    Thanks
    2
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextBlock::setVisible()

    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:

    Qt Code:
    1. QTextBlock blk = document()->begin();
    2. while (blk.isValid())
    3. {
    4. blk.setVisible(false);
    5. blk = blk.next();
    6. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Nov 2007
    Posts
    16
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTextBlock::setVisible()

    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?

  4. #4
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextBlock::setVisible()

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.