Results 1 to 3 of 3

Thread: QtextEdit add to each line strings

  1. #1
    Join Date
    Sep 2013
    Posts
    9
    Thanks
    1
    Qt products

    Default QtextEdit add to each line strings

    Heya

    This is silly but I cant break it.

    I have text in textEdit

    testa
    testb
    testc

    I want it to look like this

    testa;testb;testc;

    I got as far as getting it all in 1 line but I cant figure out how to add ; :/

    Qt Code:
    1. fromQT = self.qe.toPlainText()
    2. toPlain=str(fromQT)
    3. prefix = ''.join((';',toPlain))
    4. mystr = ''.join([line.strip() for line in prefix])
    To copy to clipboard, switch view to plain text mode 

    Thanks in advice.

  2. #2
    Join Date
    Dec 2012
    Posts
    197
    Thanks
    25
    Thanked 41 Times in 33 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QtextEdit add to each line strings

    Hello,
    Quote Originally Posted by Dariusz
    but I cant figure out how to add
    If you mean you just wanna add the text , you can add it either by passing it through the constructor when creating the text edit or by using setText method.
    Qt Code:
    1. QString myStr;
    2. QTextEdit *txtedit = new QTextEdit(myStr);
    3. txtedit->setText(myStr);
    To copy to clipboard, switch view to plain text mode 
    Take a look at other functions of QTextEdit too QTextEdit.
    Im sure you can find another way to concatenate the strings the way you want.
    Last edited by toufic.dbouk; 1st October 2013 at 23:14.

  3. #3
    Join Date
    Sep 2013
    Posts
    9
    Thanks
    1
    Qt products

    Default Re: QtextEdit add to each line strings

    Heya

    bummer I forgot to mention its python ! Sorry

    In any case the answer for my pain was

    Qt Code:
    1. myStr.replace('/n',';')
    To copy to clipboard, switch view to plain text mode 

    Thanks for help !: )

Similar Threads

  1. How do I set a QTextEdit to a specific line by line number?
    By Coolname007 in forum Qt Programming
    Replies: 8
    Last Post: 1st February 2013, 05:18
  2. Replies: 0
    Last Post: 8th December 2010, 22:32
  3. Single line QTextEdit
    By Arthur in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2010, 21:04
  4. Modifying a line in a QTextEdit
    By elcuco in forum Qt Programming
    Replies: 1
    Last Post: 15th March 2008, 16:50
  5. Replies: 5
    Last Post: 15th February 2008, 02:54

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
  •  
Qt is a trademark of The Qt Company.