Results 1 to 20 of 20

Thread: text orientation in qt

  1. #1
    Join Date
    Apr 2012
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default text orientation in qt

    Hi All,
    i want to rotate the text in the manner shown in the attachement
    i.e if the text is "abcd"
    i should rotate the each character of text by 90 degree in such a way that after i set the ttext in rotated manner , therafter whatever new character appear, they should appear in the same manner of 90 degree
    Please help regarding it.

    Thanks in advance
    Attached Images Attached Images

  2. #2
    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: text orientation in qt

    What exactly is the problem? What have you already tried to solve the problem?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2012
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: text orientation in qt

    i tried working with the following code
    Qt Code:
    1. void TextOrientation::paintEvent(QPaintEvent* event )
    2. {
    3. QString str1 = textObject->toPlainText();
    4. QByteArray ba = str1.toLocal8Bit();
    5. char *c_str2 = ba.data();
    6. painter.setFont(QFont("Arial", 20));
    7. drawRotatedText(&painter, 90,120,100, tr(c_str2));
    8. }
    9.  
    10. /************for drawing rotated text************/
    11.  
    12. void TextOrientation::drawRotatedText(QPainter *painter, float degrees, int x, int y, const QString &text)
    13. {
    14. painter->save();
    15. painter->translate(x, y);
    16. painter->rotate(degrees);
    17. // painter->scale(70,70);
    18. painter->drawText(0,0, text);
    19. painter->restore();
    20. }
    To copy to clipboard, switch view to plain text mode 

    but this will rotate only the text present currently in the textobject .
    but i want even rotation whatever new characters are being typed, they should also appear in the same rotated manner.
    Can you help me
    Last edited by wysota; 1st June 2012 at 09:17. Reason: missing [code] tags

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: text orientation in qt

    Then you need to implement keyPress() and other key-related event handlers on your TextOrientation object so that they add or remove characters to the textObject instance as the user types them. As the textObject is changed, you must call your TextOrientation object's update() method to cause a paint event.

  5. #5
    Join Date
    Apr 2012
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: text orientation in qt

    i have the code for textbox object to get updated while letters are being typed in a normal state. but once i call the paintevent , it will draw the text contained within the textbox in a specified degree. and it is not at all being included within textbox.it is getting drawn not within the textbox instead in the co-ordinates specified by me. I think i need to have some property of textbox such that once this property is set, the text typed within it will appear in the same degree rotated(ex:as once we set the italic property of font the characters within textbox and also newly typed will get displayed in italic)

  6. #6
    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: text orientation in qt

    Don't draw the whole text at once but instead draw each character one by one under the previous one.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Apr 2012
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: text orientation in qt

    can you please help me with some code as i am really new to Qt and am trying to crack it.
    I don't understand how to merge the drawn text to the textbox so that it is visible within the textbox.and not in the position specified by me while drawing it

  8. #8
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: text orientation in qt

    @Deepadev: You have confused me. I think what you are trying to say is that you have a QLineEdit or QTextEdit that the user is typing into, and you want to display the contents of the editor somewhere else (on your TextOrientation widget, I guess). Is that correct? The user is not typing directly into your TextOrientation widget, but into some other editor (QlineEdit or QTextEdit)?

    If that is the case then you should implement a slot in the TextOrientation class that handles the textChanged() signal (from QTextEdit) or textChanged(const QString &) signal (from QLineEdit), whichever one you are using to get the text from the user. In that slot, you simply call update(), which will result in a repaint of the rotated text.

    Qt Code:
    1. // TextOrientation.h:
    2.  
    3. class TextOrientation : public QWidget
    4. {
    5. Q_OBJECT;
    6.  
    7. public:
    8. // usual constructor / destructor stuff
    9.  
    10. protected slots:
    11.  
    12. void onTextChanged( const QString & text ); // assumes "textObject" is a QLineEdit
    13.  
    14. // ...
    15. };
    16.  
    17. // TextOrientation.cpp
    18.  
    19. TextOrientation::TextOrientation( QWidget * parent )
    20. : QWidget( parent )
    21. {
    22. setupUi( this );
    23.  
    24. // ... other constructor stuff as needed
    25.  
    26. connect( textObject, SIGNAL( textChanged( const QString & ) ), this, SLOT( onTextChanged( const QString & ) ) );
    27. }
    28.  
    29. void TextOrientation::onTextChanged( const QString & )
    30. {
    31.  
    32. // Ignore the new text, since TextOrientation::paintEvent() retrieves it from textObject
    33. // and just call update to schedule a repaint
    34. update();
    35. }
    To copy to clipboard, switch view to plain text mode 

  9. #9
    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: text orientation in qt

    I think he doesn't know how to paint the rotated text.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: text orientation in qt

    I think he doesn't know how to paint the rotated text.
    Could be. It isn't at all clear to me where the problem lies, and as usual there isn't enough source code to figure out what or where.

  11. #11
    Join Date
    Apr 2012
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: text orientation in qt

    i tried code something like this.
    i am a novice to Qt. so as per my knowledge , i tried something like this.
    header file
    -------------
    Qt Code:
    1. class Dialog : public QDialog
    2. {
    3. Q_OBJECT
    4. int fSize;
    5. int flag1,flag2,flag;
    6.  
    7.  
    8. public:
    9. Dialog(QWidget *parent = 0);
    10. void drawRotatedText(QPainter *painter, float degrees, int x, int y, const QString &text);
    11. QRadioButton *rBtn1,*rBtn2,*rBtn;
    12. QTextEdit *textObject;
    13. void stcpy(char *src,char* dest);
    14. void stcpy1(char *src,char* dest);
    15. void click(QPainter *painter);
    16.  
    17.  
    18. ~Dialog();
    19. protected:
    20. virtual void paintEvent(QPaintEvent *e);
    21.  
    22.  
    23. public slots:
    24. void ischecked1();
    25. void ischecked2();
    26. void ischecked3();
    27.  
    28. };
    To copy to clipboard, switch view to plain text mode 
    source file
    ----------
    Qt Code:
    1. #include "dialog.h"
    2.  
    3. Dialog::Dialog(QWidget *parent) : QDialog(parent)
    4. {
    5. fSize = 72;
    6. /**********flags for preventing crash**************/
    7. flag = 0;
    8. flag1 = 1;
    9. flag2 = 0;
    10. setGeometry(0,0,400,400);
    11. textObject = new QTextEdit(this);
    12. textObject->setGeometry(10,10,300,150);
    13. textObject->setText("deepa");
    14. textObject->setVisible(true);
    15. rBtn =new QRadioButton(this);
    16. rBtn->setVisible(true);
    17. rBtn->setGeometry(10,190,50,30);
    18. rBtn->setChecked(true);
    19. rBtn1 =new QRadioButton(this);
    20. rBtn1->setVisible(true);
    21. rBtn1->setGeometry(90,190,50,30);
    22. rBtn2 =new QRadioButton(this);
    23. rBtn2->setVisible(true);
    24. rBtn2->setGeometry(170,190,50,30);
    25.  
    26. connect(rBtn,SIGNAL(clicked()),this,SLOT(ischecked1()));
    27. connect(rBtn1,SIGNAL(clicked()),this,SLOT(ischecked2()));
    28. connect(rBtn2,SIGNAL(clicked()),this,SLOT(ischecked3()));
    29. this->setAttribute( Qt::WA_TranslucentBackground, true );
    30. }
    31.  
    32. void Dialog::ischecked1()
    33. {
    34. if(flag1 == 0)
    35. {
    36. rBtn->setCheckable(true);
    37. QString str1 = textObject->toPlainText();
    38. QByteArray ba = str1.toLocal8Bit();
    39. char *src = ba.data();
    40. char *dest = (char* )malloc(10) ;
    41. memset(dest,0,10);
    42. stcpy1(src,dest);
    43. QString string = QString::fromLocal8Bit(dest);
    44. textObject->setText(string);
    45. flag1 = 1;
    46. flag2 = 0;
    47. flag = 0;
    48. }
    49.  
    50. }
    51.  
    52.  
    53. /*************This needs to be rotated using paintevent************/
    54. void Dialog::ischecked2()
    55. {
    56. rBtn1->setCheckable(true);
    57. flag = 1;
    58. repaint();
    59. }
    60.  
    61. void Dialog::ischecked3()
    62. {
    63. if (flag2 == 0)
    64. {
    65. rBtn2->setCheckable(true);
    66. QString str1 = textObject->toPlainText();
    67. QByteArray ba = str1.toLocal8Bit();
    68. char *src = ba.data();
    69. //textObject->setFont(QFont("Arial", 10));
    70. char *dest = (char* )malloc(10) ;
    71. memset(dest,0,10);
    72. stcpy(src,dest);
    73. QString string = QString::fromLocal8Bit(dest);
    74. textObject->setText(string);
    75. flag2 = 1;
    76. flag1 = 0;
    77. flag = 0;
    78. }
    79.  
    80. }
    81.  
    82. /***********copying a string with \n to display in vertical order***********/
    83. void Dialog::stcpy(char *src,char* dest)
    84. {
    85. int i,len = 0,j=0;
    86. len=strlen(src);
    87. qDebug()<<"Length ="<<len;
    88. for(i=0;i<len;i++)
    89. {
    90. *(dest+j++) = *(src+i);
    91. *(dest+j++) = '\n';
    92. }
    93. *(dest+j) = '\0';
    94. }
    95.  
    96. /***********copying a string with \n to display in horizontal order***********/
    97. void Dialog::stcpy1(char *src,char* dest)
    98. {
    99. int i,len = 0,j=0;
    100. len=strlen(src);
    101. qDebug()<<"Length ="<<len;
    102. for(i=0;i<len;i=i+2)
    103. {
    104. *(dest+j) = *(src+i);
    105. ++j;
    106. }
    107. *(dest+j) = '\0';
    108. }
    109.  
    110.  
    111. void Dialog::paintEvent(QPaintEvent* e )
    112. {
    113. QPainter painter(this);
    114. painter.setBackgroundMode(Qt::TransparentMode);
    115. painter.setBrush(QColor(255,215,100));
    116. painter.setFont(QFont("Arial", 10));
    117. QRectF rectangle1(0, 180, 350, 40);
    118. painter.drawRect(rectangle1);
    119. painter.drawText(28,199,tr("abc"));
    120. drawRotatedText(&painter, 90,120,196, tr("abc"));
    121. painter.drawLine(195,197,195,195);
    122. painter.drawText(200,200,tr("a"));
    123. painter.drawText(200,210,tr("b"));
    124.  
    125.  
    126.  
    127. /*********functionality of second radiobutton**********/
    128.  
    129. QString str1 = textObject->toPlainText();
    130. QByteArray ba = str1.toLocal8Bit();
    131. char *c_str2 = ba.data();
    132. if(flag == 1)
    133. {
    134. painter.setPen(QColor("red"));
    135. painter.setFont(QFont("Arial", 20));
    136. drawRotatedText(&painter, 90,50,300, tr(c_str2));
    137. flag = 0;
    138. }
    139.  
    140. }
    141.  
    142. /************for drawing rotated text************/
    143.  
    144. void Dialog::drawRotatedText(QPainter *painter, float degrees, int x, int y, const QString &text)
    145. {
    146. painter->save();
    147. painter->translate(x, y);
    148. painter->rotate(degrees);
    149. // painter->scale(70,70);
    150. painter->drawText(0,0, text);
    151. painter->restore();
    152. }
    153.  
    154.  
    155.  
    156.  
    157. Dialog::~Dialog()
    158. {
    159.  
    160. }
    To copy to clipboard, switch view to plain text mode 


    But this is not working properly as i need to change the contents of textedit after this property is set so that the characters typed thereafter should appear in the same rotated format.
    Hope this will make u clear about my problem
    Last edited by wysota; 4th June 2012 at 16:32. Reason: missing [code] tags

  12. #12
    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: text orientation in qt

    What is the problem? Apart the fact you are not using layouts, of course.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Apr 2012
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: text orientation in qt

    i want the text to appear within the textbox and not in the position specified by me while drawing.
    This is not the proper method of rotating as it won't be applied to the text later typed within textbox.
    I told earlier also, that it should work like property so that once the property is set to 90 degree, the characters typed thereafter within textbox should be typed in 90 dgree angle only. For example: once we set italic property the text later typed appears in italic only within the textbox.

    is there any method to do as such?
    THANKS IN ADVANCE

  14. #14
    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: text orientation in qt

    Quote Originally Posted by DEEPADEV View Post
    I told earlier also, that it should work like property so that once the property is set to 90 degree, the characters typed thereafter within textbox should be typed in 90 dgree angle only. For example: once we set italic property the text later typed appears in italic only within the textbox.
    And the text typed earlier?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #15
    Join Date
    Apr 2012
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Re: text orientation in qt

    that tooooooo should appear rotated

  16. #16
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: text orientation in qt

    that's different to how e.g. bold and italic work
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  17. #17
    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: text orientation in qt

    Does this do what you want?

    Qt Code:
    1. #include <QtGui>
    2.  
    3.  
    4.  
    5. class RotatedText : public QWidget {
    6. Q_OBJECT
    7. Q_PROPERTY(QString text READ text WRITE setText)
    8. Q_PROPERTY(int angle READ angle WRITE setAngle)
    9. Q_PROPERTY(int letterAngle READ letterAngle WRITE setLetterAngle)
    10. Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
    11. public:
    12. RotatedText(QWidget *parent = 0) : QWidget(parent) {
    13. m_angle = 0;
    14. m_spacing = 10;
    15. m_letterAngle = 0;
    16. setBackgroundRole(QPalette::Base);
    17. setAutoFillBackground(true);
    18. }
    19. const QString &text() const { return m_text; }
    20. int angle() const { return m_angle; }
    21. int letterAngle() const { return m_letterAngle; }
    22. int spacing() const { return m_spacing; }
    23. QSize sizeHint() const { return QSize(100,100); }
    24. public slots:
    25. void setText(const QString &txt) { if(m_text == txt) return; m_text = txt; emit textChanged(m_text); update(); }
    26. void setAngle(int a) { if(m_angle == a) return; m_angle = a; emit angleChanged(a); update(); }
    27. void setLetterAngle(int a) { if(m_letterAngle == a) return; m_letterAngle = a; emit letterAngleChanged(a); update(); }
    28. void setSpacing(int s) { if(m_spacing == s) return; m_spacing = s; emit spacingChanged(s); update(); }
    29. signals:
    30. void textChanged(const QString &);
    31. void angleChanged(int);
    32. void letterAngleChanged(int);
    33. void spacingChanged(int);
    34. protected:
    35. void paintEvent(QPaintEvent *) {
    36. QPainter p(this);
    37. p.translate(width()/2, height()/2);
    38. p.rotate(m_angle);
    39. for(int i=0; i< m_text.size(); ++i) {
    40. QString letter = m_text.mid(i,1);
    41. p.save();
    42. p.translate(i*m_spacing, 0);
    43. p.rotate(m_letterAngle);
    44. p.drawText(0,0, letter);
    45. p.restore();
    46. }
    47. }
    48.  
    49. private:
    50. QString m_text;
    51. int m_angle;
    52. int m_spacing;
    53. int m_letterAngle;
    54. };
    55.  
    56. #include "main.moc"
    57.  
    58. int main(int argc, char **argv) {
    59. QApplication app(argc, argv);
    60.  
    61. QVBoxLayout *l = new QVBoxLayout(&w);
    62. QLineEdit *le = new QLineEdit;
    63. l->addWidget(le);
    64. le->setPlaceholderText("Enter text");
    65. RotatedText *txt = new RotatedText;
    66. l->addWidget(txt);
    67. QObject::connect(le, SIGNAL(textChanged(QString)), txt, SLOT(setText(QString)));
    68. le->setText("Some example text");
    69. QSlider *angle = new QSlider(Qt::Horizontal);
    70. l->addWidget(angle);
    71. angle->setRange(0, 359);
    72. angle->setValue(txt->angle());
    73. QObject::connect(angle, SIGNAL(valueChanged(int)), txt, SLOT(setAngle(int)));
    74. QSlider *letterAngle = new QSlider(Qt::Horizontal);
    75. l->addWidget(letterAngle);
    76. letterAngle->setRange(0, 359);
    77. letterAngle->setValue(txt->letterAngle());
    78. QObject::connect(letterAngle, SIGNAL(valueChanged(int)), txt, SLOT(setLetterAngle(int)));
    79. QSlider *spacing = new QSlider(Qt::Horizontal);
    80. l->addWidget(spacing);
    81. spacing->setRange(0,100);
    82. spacing->setValue(txt->spacing());
    83. QObject::connect(spacing, SIGNAL(valueChanged(int)), txt, SLOT(setSpacing(int)));
    84.  
    85. QPushButton *button = new QPushButton("Pause animation");
    86. button->setCheckable(true);
    87. QPropertyAnimation *a1 = new QPropertyAnimation(angle, "value", button);
    88. QPropertyAnimation *a2 = new QPropertyAnimation(letterAngle, "value", button);
    89. a1->setLoopCount(-1);
    90. a2->setLoopCount(-1);
    91. a1->setDuration(9000);
    92. a2->setDuration(5000);
    93. a1->setStartValue(angle->value());
    94. a2->setStartValue(letterAngle->value());
    95. a1->setEndValue(359);
    96. a2->setEndValue(359);
    97. a1->start();
    98. a2->start();
    99. QObject::connect(button, SIGNAL(toggled(bool)), a1, SLOT(setPaused(bool)));
    100. QObject::connect(button, SIGNAL(toggled(bool)), a2, SLOT(setPaused(bool)));
    101. l->addWidget(button);
    102.  
    103. w.show();
    104.  
    105. return app.exec();
    106. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  18. #18
    Join Date
    Apr 2012
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: text orientation in qt

    Thanks a lot. You gave me more than what i needed.I will try to implement it as per my requirements.

  19. #19
    Join Date
    Apr 2012
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: text orientation in qt

    The above code works perfectly fine but was not able to implement it within the Qtextedit object as it was not editable within that. So i used the following code for vertical orientation of text character by character and is working for me

    Qt Code:
    1. void Orientation::Btn_clicked()
    2. {
    3. QString str1 = textedit->toPlainText();
    4. QByteArray ba = str1.toLocal8Bit();
    5. char *src = ba.data();
    6. char *dest = (char* )malloc(strlen(src)+1) ;
    7. memset(dest,0,strlen(src)+1);
    8. stcpy(src,dest);
    9. QString string = QString::fromLocal8Bit(dest);
    10. textedit->setText(string);
    11. }
    12. }
    13.  
    14. /***********copying a string with \n to display in vertical order***********/
    15. void Orientation::stcpy(char *src,char* dest)
    16. {
    17. int i,len = 0,j = 0;
    18. len=strlen(src);
    19. for(i=0;i<len;i++)
    20. {
    21. *(dest+j++) = *(src+i);
    22. *(dest+j++) = '\n';
    23. }
    24. *(dest+j) = '\0';
    25. }
    To copy to clipboard, switch view to plain text mode 



    Also i am attaching the code for rotation as may be it is useful for freshers of Qt.
    I have done it within Qtextedit paintevent


    Qt Code:
    1. void textedit::paintEvent(QPaintEvent *e)
    2. {
    3. QPainter painter(viewport());
    4. painter.rotate(Angle);
    5. painter.translate(xPos,yPos);
    6.  
    7. QAbstractTextDocumentLayout::Selection selection;
    8. selection.cursor = textCursor();
    9. selection.format = textCursor().charFormat();
    10. QAbstractTextDocumentLayout::PaintContext ctx;
    11. ctx.cursorPosition = textCursor().position();
    12. ctx.selections.append(selection);
    13. document()->documentLayout()->draw(&painter,ctx);
    To copy to clipboard, switch view to plain text mode 
    u can specify the angle of rotation and the co-ordinates to be visible in the above code and use it for rotating the text.It is editable as we are rotating the layout and not drawing the text.
    Hope this code will others like me.
    If further improvements can be done to this code please do mention.
    This site helped me a lot. Thankyou
    Last edited by wysota; 19th June 2012 at 09:50. Reason: missing [code] tags

  20. #20
    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: text orientation in qt

    Why didn't you say you wanted the text to be part of QTextEdit? We'd have told you that you were supposed to implement your own QTextObject for that...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Text orientation in header from QStandardItemModel
    By Tondog in forum Qt Programming
    Replies: 3
    Last Post: 2nd October 2012, 08:39
  2. QListWidgetItem's icon and text orientation
    By circass in forum Qt Programming
    Replies: 5
    Last Post: 17th June 2010, 08:03
  3. QTabBar Text and Icon orientation
    By Gravis in forum Qt Programming
    Replies: 0
    Last Post: 16th December 2009, 08:55
  4. QLineEdit text orientation
    By emrares in forum Qt Programming
    Replies: 7
    Last Post: 15th September 2009, 06:25
  5. Vertical Orientation of Text.
    By ashukla in forum Qt Programming
    Replies: 9
    Last Post: 28th January 2008, 12:40

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.