PDA

View Full Version : Page based rich text editor



webstar2568
27th April 2011, 19:05
Hi there,

I'm currently writing a small editor application. Now I want to build an page based editor (like OO Writer, MS Word...). Is there a possibility doing that in Qt, even with rich text? The QPrintPreviewWidget can display rich text like that, but content displayed there is of course not editable.

I'm using Qt 4.7.

I'll hope that someone has an idea for that.

AlexSudnik
27th April 2011, 21:23
There's a Rich Text section in Qt examples,take a look at it...

webstar2568
28th April 2011, 05:37
Hi,

thanks for the reply. Of course, rich text editing in Qt is no problem. The problem is, that it must be page based.

Any ideas?

AlexSudnik
28th April 2011, 09:20
I guess you can try to calculate the amount of text per page and once it's exceeded , create a new instance of a page and textEditor (that will use the page's layout ).Although it's just my suggestion , and too abstract :)

webstar2568
28th April 2011, 09:45
Hi,

well, yes, that was also my plan. But there are a lot of problems: There is no possibility to get the height of a QTextBlock. There is no possibility to get the HTML for the QTextBlock. And there is no real possibility to remove or add them.

If someone has a solution for one of theese problems, it would help a lot.

MaKo
4th November 2011, 13:49
Hi, I am interested exactly from the same thing. I have been writing an editor (https://gitorious.org/moe) and I would like to implement OpenOffice-like "contiguous view". The text is stored in separate QStrings, and they are organized as a tree. I have planned to create a scrollable area, place vertical box layout on it, go through the tree and create QLineEdit & QTextEdit objects to layout. Quite simple this far? But the problems have arised from:

- How to make text edit box to take as much vertical space as needed to show the contents? I have used fixed size, but then, when you edit, the box does not shrink/grow. Is there any other ways to do this than connect a bunch of signals to some sort of resize routine to calculate new height for the element?

- Getting the edit components and scrollable area to work together: for example, when cursor goes out of visible area, make the scrollable area to scroll it visible again (like OO and similar do).

- Moving between components (pg up/dn, cursor keys)

I have thought an alternative, using just one single textedit box, and adding some hidden (and non-destructible) fields to content to tell where to find the corresponding QString to save the result. Would it be possible/easier?

Anyways, I probably have lots of problems to keep the editor boxes and tree itself synchronized together, when user edits, moves and deletes parts of the text...