Results 1 to 14 of 14

Thread: Changing the Text Pattern?

  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

    Question Changing the Text Pattern?

    Dear All!
    I am using the following code for changing the Text Pattern;
    Qt Code:
    1. QPalette palette;
    2. QBrush brush(fg);
    3. QBrush brush1(fg);
    4. brush.setStyle(Qt::HorPattern);
    5. palette.setBrush(QPalette::Active, QPalette::Text, brush);
    6. palette.setBrush(QPalette::Inactive, QPalette::Text, brush1);
    7. QBrush brush2(bg);
    8. brush2.setStyle(Qt::SolidPattern);
    9. palette.setBrush(QPalette::Active, QPalette::Base, brush2);
    10. textEdit->setPalette(palette);
    To copy to clipboard, switch view to plain text mode 
    but it is not change its Text Pattern Horizontal. However, I applied this upon Background of the QTextEdit, It applies.

    How to get the Horizontal patterns in Text of QTextEdit.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  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: Changing the Text Pattern?

    I think the text is not drawn using the widget's brush. You might try changing the text block's format options instead.

  3. #3
    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: Changing the Text Pattern?

    Quote Originally Posted by wysota View Post
    I think the text is not drawn using the widget's brush. You might try changing the text block's format options instead.
    Dear Sir!
    Please give me any example or link of this?
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  4. #4
    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: Changing the Text Pattern?

    J-P Nurmi

  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

    Question Re: Changing the Text Pattern?

    Quote Originally Posted by jpn View Post
    Dear Sir!
    I want the result as on attached Screen Shots.
    The above is not suitable for me.
    What should I do for this?
    Attached Files Attached Files
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  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: Changing the Text Pattern?

    What did you already try?

  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: Changing the Text Pattern?

    Quote Originally Posted by wysota View Post
    What did you already try?
    Dear Sir!
    As you said earlier I have searched many classes for that but I am unanble to found any useful function for this.
    Mr. JPN has said use
    See for example QTextEdit::setCurrentCharFormat().
    __________________
    Merry Christmas -- J-P Nurmi
    but It's not usful in this case.
    Please give me any suggestion in right direction to acheive the goal.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  8. #8
    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: Changing the Text Pattern?

    Have you written any code to test any of the given ideas?

  9. #9
    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: Changing the Text Pattern?

    Quote Originally Posted by wysota View Post
    Have you written any code to test any of the given ideas?
    Dear Sir!
    No, b/z I have not gotten any function for that.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  10. #10
    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: Changing the Text Pattern?

    If not, then how come you say the given answers are useless if you didn't even bother to try them out? Have you acceessed the document of the text edit? Have you accessed the text block you want to change? Did you have a look at available options for the block of text?

  11. #11
    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: Changing the Text Pattern?

    Quote Originally Posted by wysota View Post
    If not, then how come you say the given answers are useless if you didn't even bother to try them out? Have you acceessed the document of the text edit? Have you accessed the text block you want to change? Did you have a look at available options for the block of text?
    Dear Sir!
    I depicted carefully above ideas.
    void QTextEdit::setCurrentCharFormat ( const QTextCharFormat & format )
    It takes a arguments of QTextCharFormat object.
    That only provides the following features;
    Qt Code:
    1. void setAnchorNames ( const QStringList & names )
    2. void setFont ( const QFont & font )
    3. void setFontFamily ( const QString & family )
    4. void setFontFixedPitch ( bool fixedPitch )
    5. void setFontItalic ( bool italic )
    6. void setFontOverline ( bool overline )
    7. void setFontPointSize ( qreal size )
    8. void setFontStrikeOut ( bool strikeOut )
    9. void setFontUnderline ( bool underline )
    10. void setFontWeight ( int weight )
    11. void setTextOutline ( const QPen & pen )
    12. void setToolTip ( const QString & text )
    13. void setUnderlineColor ( const QColor & color )
    14. void setUnderlineStyle ( UnderlineStyle style )
    15. void setVerticalAlignment ( VerticalAlignment alignment )
    16. QPen textOutline () const
    17. QString toolTip () const
    18. QColor underlineColor () const
    19. UnderlineStyle underlineStyle () const
    20. VerticalAlignment verticalAlignment () const
    To copy to clipboard, switch view to plain text mode 

    And the QTextBlock and QTextBlockFormat only provides the facility of indentation, pargraph settings etc.

    So, that's the reason I have not wriiten any line of code for that b/z I am unable to find the right function until now.

    So, If any function exists; please advice me for that.
    Thanking you!
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  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: Changing the Text Pattern?

    And what does QPen provide?

    BTW. I was talking about the document, not the widget that display it.
    Last edited by wysota; 28th December 2007 at 12:46.

  13. #13
    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: Changing the Text Pattern?

    Quote Originally Posted by ashukla View Post
    It takes a arguments of QTextCharFormat object.
    That only provides the following features;
    Notice that QTextCharFormat is a QTextFormat.
    J-P Nurmi

  14. #14
    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

    Dear JPN!
    Thanks for your reply!
    However It is working well for Qt::TexturePattern, Qt:enseXPattern (here X means 1,2,3 ....7);
    But I am not getting the horizontal pattern as I have attached the previous file.
    So, What I change in my code;
    Qt Code:
    1. QBrush brush(Qt::blue,Qt::HorPattern);
    2. format.setForeground(brush);
    3. QTextCursor cursor = txtScrollEdit->textCursor();
    4. if (!cursor.hasSelection())
    5. cursor.select(QTextCursor::Document);
    6. cursor.mergeCharFormat(format);
    7. txtScrollEdit->setFontPointSize(28);
    8. txtScrollEdit->setFontWeight(QFont::Bold);
    9. txtScrollEdit->mergeCurrentCharFormat(format);
    To copy to clipboard, switch view to plain text mode 
    to get the desired output.

    I am getting the output as attached in the sample.png. So, How a way I get output as I have attached earlier.
    Attached Images Attached Images
    Last edited by wysota; 29th December 2007 at 12:19. Reason: Posts merged

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. Replies: 3
    Last Post: 20th November 2007, 07:03
  4. Editable text in QGraphicsView
    By wysota in forum Qt Programming
    Replies: 8
    Last Post: 24th February 2007, 15:30
  5. Changing the text color of a QTreeView leaf.
    By johnny_sparx in forum Qt Programming
    Replies: 3
    Last Post: 22nd March 2006, 23:58

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.