Results 1 to 9 of 9

Thread: How to handle amount of text blocks?

  1. #1
    Join Date
    Jan 2014
    Posts
    6
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Question How to handle amount of text blocks?

    Hi Guys,

    I would like to know if there is one solution to handle thousands of text blocks and set invisible to them at one time?

    It is very slow if the program set visible as false/true as block by block.

    Thank you in advance

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to handle amount of text blocks?

    Do you mean QTextBlocks in a QTextDocument?

  3. #3
    Join Date
    Jan 2014
    Posts
    6
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to handle amount of text blocks?

    Yes, Chris.

    I am not quite sure if we can control the attributes of text in the block with paint or draw event as it should be faster rather than setting the visible to true/false for thousands of blocks.

    Thanks

    Or is there any frame to warp the text block and we can simply add blocks into a container and set visibility to the container at one time?

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to handle amount of text blocks?

    Some options to explore to improve performance.

    If the document is visible then each time you change the visibility of a block the widget will get an update event. So, try calling textEdit->setUpdatesEnabled(false), process the visibility of blocks, then textEdit->setUpdatesEnabled(true).

    I am not sure if QTextDocument tracks block visibility with undo events, so you could try also try wrapping the changes with document->setUndoRedoEnabled().

  5. #5
    Join Date
    Jan 2014
    Posts
    6
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to handle amount of text blocks?

    Thanks Chris.

    I will have a try and let you know then

  6. #6
    Join Date
    Jan 2014
    Posts
    6
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to handle amount of text blocks?

    Unfortunately, it does not work by seting setUpdateEnabled to true/false and it is still slow. the change history does not save the action for visibility setting.

  7. #7
    Join Date
    Jan 2014
    Posts
    6
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to handle amount of text blocks?

    I plan to use QTimer and set interval as 40 min sec then it should be resolved.

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to handle amount of text blocks?

    What does a timer have to do with the topic of this thread?

  9. #9
    Join Date
    Jan 2014
    Posts
    6
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to handle amount of text blocks?

    Hi Chris,

    Because of there are 10k text blocks need to be set visibility as show/hidden, I would like to allow the program to process 1000 blocks every 40 min secs with QTimer until all of them are finalized, then it should be resolved as I expected but I have not modified yet.

    I tried to use QTextLayout, QTextLine, QPlainTextDocumentLayout and QTextFrame, they are not working for this case.

    Please correct me if I am wrong

    Thanks

Similar Threads

  1. example of QPlainTextEdit subclass to handle large text files
    By nekkro-kvlt in forum Qt Programming
    Replies: 2
    Last Post: 17th October 2012, 14:30
  2. Is there any way to traverse amount of controls in a loop?
    By mismael85 in forum Qt Programming
    Replies: 5
    Last Post: 29th November 2010, 09:31
  3. Limit Amount of Text in a QTextEdit
    By johnmauer in forum Newbie
    Replies: 1
    Last Post: 10th January 2010, 16:53
  4. How to read only a certain amount of bytes
    By Morea in forum Qt Programming
    Replies: 1
    Last Post: 28th January 2009, 07:38
  5. amount of items in QTreeWidget
    By supergillis in forum Qt Programming
    Replies: 4
    Last Post: 1st August 2008, 22:38

Tags for this Thread

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.