Results 1 to 10 of 10

Thread: Vertical Orientation of Text.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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 Vertical Orientation of Text.

    Qt Code:
    1. #include <QtGui>
    2.  
    3. class W : public QWidget {
    4. public:
    5. W() : QWidget(){}
    6.  
    7. protected:
    8. void paintEvent(QPaintEvent *e){
    9.  
    10. QTextLayout textLayout( "Hello How are you!");
    11. QFontMetrics fontMetrics(QApplication::font());
    12. int leading = fontMetrics.leading();
    13. int height = 0;
    14. qreal widthUsed = 0;
    15. textLayout.beginLayout();
    16. while (1) {
    17. QTextLine line = textLayout.createLine();
    18. if (!line.isValid())
    19. break;
    20.  
    21. line.setLineWidth(9);
    22. //line.setNumColumns (1);
    23. height += leading;
    24. line.setPosition(QPoint(0, height));
    25. height += line.height();
    26. widthUsed = qMax(widthUsed, line.naturalTextWidth());
    27. }
    28. textLayout.endLayout();
    29. QWidget::paintEvent(e);
    30. QPainter p(window());
    31. QPen pe = p.pen();
    32. pe.setWidth(4);
    33. pe.setColor(Qt::red);
    34. p.setPen(pe);
    35. textLayout.draw(&p, QPoint(0, 0));
    36. }
    37. };
    38.  
    39. int main(int argc, char **argv){
    40. QApplication app(argc, argv);
    41. W w;
    42. w.show();
    43. w.resize(300,200);
    44. return app.exec();
    45. }
    To copy to clipboard, switch view to plain text mode 
    I am getting the output as attachments;
    but I wants as
    H
    e
    l
    l
    o

    H
    o
    w

    a
    r
    e

    y
    o
    u
    !
    What should I do in code for this;
    Attached Images Attached Images
    • File Type: png h.png (19.6 KB, 83 views)
    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, 09:49
  2. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 14:36
  3. Vertical text in a QTextDocument
    By Angelo Moriconi in forum Qt Programming
    Replies: 6
    Last Post: 7th February 2008, 05:30
  4. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 12:05
  5. Editable text in QGraphicsView
    By wysota in forum Qt Programming
    Replies: 8
    Last Post: 24th February 2007, 15: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.