Results 1 to 7 of 7

Thread: Vertical text in a QTextDocument

  1. #1
    Join Date
    Jan 2007
    Location
    Rome
    Posts
    30
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Vertical text in a QTextDocument

    I need to have a QTextDocument that display vertical text. Probably, reading the documentation, I need to create a new layout that draw every single character moving everytime down.

    Just to avoid confusion I don't want to rotate also the characters (I know that I can simple rotate all the widget using a QTransform) I need to have something like that:

    H
    E
    L
    L
    O

    W
    O
    R
    L
    D

    There is a simple way to have vertical text inside a QTextDocument or I need to reimplement a QDocumentLayout ?

    Thanks in advance,

    Angelo

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Vertical text in a QTextDocument

    does it mean you want your QTextDocument to be just one vertical line?
    What re the rules for this vertical layout?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2007
    Location
    Rome
    Posts
    30
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Vertical text in a QTextDocument

    No, I need vertical text in multiple lines.
    I want to write vertically and then , when I press return going in another line (on the right).

    So, vertical text drawing from left to right, like Japanese writing.

    Currently I cannot find a solution, I have to study the QTextLayout in order to create a custom layout suitable for this.

    Best,

    Angelo

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Vertical text in a QTextDocument

    You'll need to provide your own layout engine derived from QAbstractTextDocumentLayout.

  5. #5
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Vertical text in a QTextDocument

    Dear Angelo!
    Qt Code:
    1. sl=txtScrollEdit->toPlainText().split(" ");
    2. txtScrollEdit->setText(sl.join("\n\n"));
    3. txtScrollEdit->setWordWrapMode (QTextOption::WrapAnywhere);[COLOR="Red"]// txtScrollEdit is QTextEdit[/COLOR]
    4. txtScrollEdit->setLineWrapMode(QTextEdit::FixedColumnWidth);
    5. txtScrollEdit->setLineWrapColumnOrWidth(1);
    To copy to clipboard, switch view to plain text mode 
    Hope it helps!
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  6. #6
    Join Date
    Jan 2007
    Location
    Rome
    Posts
    30
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Vertical text in a QTextDocument

    Thanks Ashuklafor the quick reply.
    Probably this method should work, but I currently use a QGraphicsTextItem in which there isn't the possibility to set the lineWrapMode.

    I must use this kind of widget since currently I need to scale the text according to the view and the textEdit widget doesn't allow to do that. But this is another issue

    Best,

    Angelo

  7. #7
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Vertical text in a QTextDocument

    Dear Angelo!
    Qt Code:
    1. item->setDocument(txtScrollEdit); [COLOR="Red"]//txtScrollEdit is a QTextEdit[/COLOR]
    To copy to clipboard, switch view to plain text mode 
    By the above way you can set the lineWrapMode implicitly.
    Hope its help!
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 10:49
  2. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 15:36
  3. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 13:05
  4. QTextDocument stinks
    By elcuco in forum Qt Programming
    Replies: 4
    Last Post: 24th July 2007, 13:30
  5. Editable text in QGraphicsView
    By wysota in forum Qt Programming
    Replies: 8
    Last Post: 24th February 2007, 16:30

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.