QPlainTextEdit resizeEvent not triggered on making document's blocks visible/invisible



  • I am using QT 4.8 to implement a class (derived from QPlainTextEdit) to log messages, which offers the functionality of folding/unfolding a set of messages. Each message is a QTextBlock.

    class MessageLog : public QPlainTextEdit
    {
       foldOrUnfoldTextBlocks(....)
       {
           // folds/unfolds a set of text blocks by QTextBlock's setVisible() API
           document()->documentLayout()->requestUpdate();
       }
    }
    

    The function foldOrUnfoldTextBlocks() does not trigger the resizeEvent() of MessageLog which leads to some messages being cut at the bottom on unfolding and leaves extra space at the bottom on folding.
    How is resizeEvent() supposed to be triggered on making text blocks visible/invisible in the document?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What exactly are you trying to resize for ?



  • Hi SGaist,

    The resize of QPlainTextEdit is required in following two scenarios:

    • On making some of the invisible QtextBlocks visible, the size of the document changes. To accommodate the extra blocks, the QPlainTextEdit needs to be resized otherwise some of the blocks will be cut at the bottom
    • On making visible blocks invisible, extra white space will be left at the end in QPlainTextEdit

  • Lifetime Qt Champion

    Is your QPlainTextEdit in a layout ?



  • @SGaist QPlainTextEdit is in a QStackedWidget which is in a QVBoxLayout


  • Lifetime Qt Champion

    In that case, the resize of QPlaintTextEdit is managed by QVBoxLayout which manages QStackedWidget which manages your QPlainTextEdit.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.