Important: Please read the Qt Code of Conduct -

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 sets visiblility to false/true as block by block.

    Thank you in advance

  • Hi toyman,

    you mean in QML? If so, why not using property binding triggered by a "global" property e.g. in your root QML file?

    Let's say your root QML file is called "main.qml":

    Item {
    id: main

    property bool globalTextVisibleFlag: true // or false, whatever you need here


    And in the QMLs using your Text blocks:

    Text {
    visible: main.globalTextVisibleFlag

    This allows to set all those text blocks' visibility by one single property change like:
    function setAllTextVisibility(newVisibility) {
    main.globalTextVisibleFlag = newVisibility

    Hope this helps
    Regards, edmon

  • Thanks, edmon.

    It is C++ application not QML.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You might be interested by "this":

    Hope it helps

  • Hi SGaist,

    Thanks for your help.

    I tried this before but it is still busy to process the visibility for each text block and it has around 10k blocks to be implemented.

    I actually added the setUpdatesEnabled(false) for QPlainTextEdit object before the loop and inserted setUpdatedEnabled(true) after the loop.

    It should stop updating and painting until the visibility has been set and then continue to paint and update for QPlainTextEdit. However, it is still very slow to process.

  • I may have some wrong steps and please correct me :)

  • I found that the text frame (QTextFrame) can warp text blocks but it does not provide any functions in order to set visibility.

    It there anything can be done with layout or format to achieve this?

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

Log in to reply