Results 1 to 9 of 9

Thread: How to add a new word to QTextEdit with "append"

  1. #1
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default How to add a new word to QTextEdit with "append"

    Hello,

    How can i append a line or word in QTextEdit with append(or another way) without making a new paragraph.I mean;
    let's say in QTextEdit we have "Hello":

    Hello

    I wanna add "world":

    Qt Code:
    1. textEdit->append("world")
    To copy to clipboard, switch view to plain text mode 

    will give the result:

    Hello
    world
    but i want:

    Hello world
    Last edited by jpn; 3rd January 2008 at 13:36. Reason: reformatted to look better

  2. #2
    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 to add a new word to QTextEdit with "append"

    J-P Nurmi

  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: How to add a new word to QTextEdit with "append"

    Quote Originally Posted by jpn View Post
    Dear JPN!
    I am using a format() function
    Qt Code:
    1. void dlgTextScroller::format()
    2. {
    3. QBrush brush(QImage::QImage("rose.jpg"));
    4. brush.setStyle(Qt::TexturePattern);
    5.  
    6. format.setForeground(brush);
    7.  
    8. QTextCursor cursor = txtScrollEdit->textCursor();
    9. if (!cursor.hasSelection())
    10. cursor.select(QTextCursor::Document);
    11. cursor.setCharFormat(format);
    12. txtScrollEdit->setCurrentCharFormat(format);
    13. }
    To copy to clipboard, switch view to plain text mode 
    for formatting the txtScrollEdit Text.
    then for Animation of formatted text I am using;
    Qt Code:
    1. scrItem->setDocument(txtScrollEdit->document());
    To copy to clipboard, switch view to plain text mode 
    In this case my text appears as
    Qt Code:
    1. Hello
    2. world
    To copy to clipboard, switch view to plain text mode 
    How to gain formatted text for animation in one line.
    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: How to add a new word to QTextEdit with "append"

    Quote Originally Posted by ashukla View Post
    In this case my text appears as
    Qt Code:
    1. Hello
    2. world
    To copy to clipboard, switch view to plain text mode 
    How to gain formatted text for animation in one line.
    Umm, what does the code you pasted have to do with this? I don't see anything that appends or inserts any text at all. All I see is some formatting which applies a texture.
    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

    Default Re: How to add a new word to QTextEdit with "append"

    Quote Originally Posted by jpn View Post
    Umm, what does the code you pasted have to do with this? I don't see anything that appends or inserts any text at all. All I see is some formatting which applies a texture.
    Dear Sir!
    I want to animate txtScrollEdit texture formatted text in
    Qt Code:
    1. scrItem->setDocument(txtScrollEdit->document());
    To copy to clipboard, switch view to plain text mode 
    When Iwrite text using with 36 point font size It goes to next line. And thats the reason when I setDocument() using with above scrItem it goes on the next line. However I want to animate formatted texture text as same as
    Qt Code:
    1. QGraphicsTextItem *scrItem = new GraphicsTextItem(txtScrollEdit->toPlainText());
    To copy to clipboard, switch view to plain text mode 
    in a single line.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  6. #6
    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 to add a new word to QTextEdit with "append"

    Have you tried to play with QGraphicsTextItem::setTextWidth()?
    J-P Nurmi

  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: How to add a new word to QTextEdit with "append"

    Quote Originally Posted by jpn View Post
    Have you tried to play with QGraphicsTextItem::setTextWidth()?
    Sir!
    Qt Code:
    1. scrItem->setDocument(txtScrollEdit->document());
    2. scrItem->setTextWidth(-1);
    To copy to clipboard, switch view to plain text mode 
    I am using above but it shows only the first line of QTextEdit; However, I have not inserted any enter in QTextEdit txtScrollEdit.
    So, What should I do?
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  8. #8
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: How to add a new word to QTextEdit with "append"

    Thank you jpn, i ve been looking for that..!

  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: How to add a new word to QTextEdit with "append"

    Quote Originally Posted by yagabey View Post
    Thank you jpn, i ve been looking for that..!
    you can use
    Qt Code:
    1. txtScrollEdit->setWordWrapMode (QTextOption::NoWrap); //txtScrollEdit is QTextEdit object
    To copy to clipboard, switch view to plain text mode 
    before the
    Qt Code:
    1. scrItem->setDocument(txtScrollEdit->document());
    2. scrItem->setTextWidth(-1);
    To copy to clipboard, switch view to plain text mode 
    .
    It sets the document in one line.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

Similar Threads

  1. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 14:36
  2. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 06:03

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.