[Qt-interest] How to implement text editor with Qt in CView?

cheng long kevinclcn at gmail.com
Thu May 6 10:19:33 CEST 2010


Hi,

I am implementing a text editor with Qt in my MFC application. I've met some
issues and hope to get your suggestions here.

Our roughly requirements are:
1) Text shown in canvas (2D/3D) – *non-edit mode*;
2) Text can be zoomed in scale;
3) Text can be edited after double clicking left mouse button – *edit mode*.
4) Text has the same visual in both non-edit mode and edit mode.



My current idea is:
1) Show the text in an image – *non-edit mode*;
2) When zooming, repaint the image with QPainter and scale it with
QPainter.scale();
3) When editing, show a QTextEdit upon the image – *edit mode*.
4) *ISSUES HERE! *I need QTextEdit to have the same zooming ability as
QPainter.scale(), i.e. if the image has been zoomed up to 200% in non-edit
mode,  the QTextEdit, when shown in edit mode, should also be zoomed to
200%: twice as big as the original one and so is the text in it. The
QTextEdit::zoomIn()/zoomOut() is not acceptable for it changes font size.
Overriding the QTextEdit::paintEvent() is also not okay, for it uses many
QTextEditPrivate stuff.

 My questions are:
1) Is my approach correct? If yes, how to make QTextEdit scalable?
2) Are there any other possibilities to achieve our goals?
3) QGraphicsTextItem can satisfy our requirements to some extent, is it can
be used in a CView? As you know, My application is MFC based.

Any thoughts would be appreciated!

Thank you very much!
Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100506/b7681565/attachment.html 


More information about the Qt-interest-old mailing list