i have a QTextEdit document which size is different by every print. In the middle of the document i have few blocks of text which are inseparable in the eyes of the user and i have to protect my blocks from splitting on two pages in case the document gets equivalent size. Have you got any solution?
Share
I am a great fan of Qt but I have not had an opportunity yet to use a QTextEdit. I would like to help though so I took a look through the documentation.
If you are using a sufficiently recent version of Qt you should find that a QTextEdit has an associated QTextDocument and it would seem that the functionality you seek may be there. A QTextDocument is a hierarchy of frames and blocks. A block is equivalent to a paragraph as you mention above.
The documentation seems to indicate that you could specify that your blocks be wrapped in a frame. Then, you should be able to set a format for the frame using QTextFrame::setFrameFormat. This format will allow you to specify a page break policy using some flags. The flags that are specified are PageBreak_Auto, PageBreak_AlwaysBefore and PageBreak_AlwaysAfter.
It would seem to me that if you set both the PageBreak_AlwaysBefore and PageBreak_AlwaysAfter flags for the frame, then your blocks should stay together.
I realize this is a fairly complex series. I hope that it helps and would really like to hear if it works.