Results 1 to 7 of 7

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

  1. #1
    Join Date
    Nov 2007
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default How can I implement a text editor which display it's contents from top to bottom?

    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!
    Attached Images Attached Images
    • File Type: jpg 1.JPG (2.6 KB, 39 views)

  2. #2
    Join Date
    Jan 2006
    Posts
    371
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I implement a text editor which display it's contents from top to bottom?

    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

  3. The following user says thank you to elcuco for this useful post:

    cslijy (26th November 2007)

  4. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How can I implement a text editor which display it's contents from top to bottom?

    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    cslijy (26th November 2007)

  6. #4
    Join Date
    Nov 2007
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: How can I implement a text editor which display it's contents from top to bottom?

    Quote Originally Posted by jpn View Post

    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?

  7. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How can I implement a text editor which display it's contents from top to bottom?

    Man, that's weird requirement. Perhaps you could lay the text by hand with help of QTextLayout.
    J-P Nurmi

  8. #6
    Join Date
    Nov 2007
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: How can I implement a text editor which display it's contents from top to bottom?

    Quote Originally Posted by jpn View Post
    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?

    Qt Code:
    1. //Here is some code in paint
    2. textLayout.beginLayout();
    3. while (1) {
    4. QTextLine line = textLayout.createLine();
    5. if (!line.isValid())
    6. break;
    7. line.setLineWidth(200);
    8. line.setPosition(QPoint(0,height));
    9. height += (int) line.height();
    10. }
    11. myheight+=height;
    12. textLayout.endLayout();
    13. textLayout.draw(painter,QPointF(0,myheight));
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 9th January 2008 at 15:50.

  9. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How can I implement a text editor which display it's contents from top to bottom?

    You'll need to do the blinking cursor yourself with help of a timer.
    J-P Nurmi

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.