PDA

View Full Version : How can I implement a text editor which display it's contents from top to bottom?



cslijy
25th November 2007, 04:57
I try to implement a text editor which display it's contents from top to bottom (like picture shown). Could you give me some suggestions? Thank you!

elcuco
25th November 2007, 10:27
In Qt4.4 you can put a QTextEditor into a QGraphicsScene. Now sure how trivial it is... and how "fast" do you need this, but it's a start :)

jpn
25th November 2007, 12:59
Wouldn't plain QGraphicsTextItem suffice? Adjust QGraphicsTextItem::interactionFlags() and QGraphicsItem::rotate().

cslijy
8th January 2008, 08:43
Wouldn't plain QGraphicsTextItem suffice? Adjust QGraphicsTextItem::interactionFlags() and QGraphicsItem::rotate().


I rotate the item,but the secord line appeared on left of first line.How can I make the secorn line displayed on right of the first line?

jpn
8th January 2008, 09:07
Man, that's weird requirement. :eek: Perhaps you could lay the text by hand with help of QTextLayout.

cslijy
9th January 2008, 02:44
Perhaps you could lay the text by hand with help of QTextLayout.



I tried QTextLayout and got the right alignment.But the Item does not display when I am typing.As soon as I press Enter,the Item displays the line that I just input at one moment.And the textcursor does not flash.I guess it may be the item refresh region is not my layout region.Can you give me some advise?


//Here is some code in paint
textLayout.beginLayout();
while (1) {
QTextLine line = textLayout.createLine();
if (!line.isValid())
break;
line.setLineWidth(200);
line.setPosition(QPoint(0,height));
height += (int) line.height();
}
myheight+=height;
textLayout.endLayout();
textLayout.draw(painter,QPointF(0,myheight));

jpn
9th January 2008, 16:56
You'll need to do the blinking cursor yourself with help of a timer.