Results 1 to 4 of 4

Thread: Modifying a text

  1. #1
    Join Date
    Dec 2007
    Location
    Brazil
    Posts
    61
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Modifying a text

    Hello staff!

    I have the following:

    tr("<p>CDP Range First CDP 771 Last CDP 17146, " \
    "Num. of CDPs 16376 CDPs." \
    "<p>CDP Interval 6.25" \
    "Total Distance 102350 Meters.")

    I'm printing this in a file that will be used later. Only that the numbers will be constantly changed by the user. When the user clicking the "button", the numbers are in a "line edit" that must replace the text.
    Excuse me the english, I'm Brazilian.
    Somebody can help me?

  2. #2
    Join Date
    Apr 2008
    Location
    Pavlodar, Kazakhstan
    Posts
    22
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Modifying a text

    Take a look at QString::arg function.

  3. #3
    Join Date
    Dec 2007
    Location
    Brazil
    Posts
    61
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Modifying a text

    But the text should contain many lines. Then I use several QString::arg?

  4. #4
    Join Date
    Apr 2008
    Location
    Pavlodar, Kazakhstan
    Posts
    22
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Modifying a text

    Yes. Your code may look like this:
    Qt Code:
    1. QString firstCDP = tr("771");
    2. QString lastCDP = tr("17146");
    3. QString string = QString(tr("<p>CDP Range First CDP %1 Last CDP %2, ")).arg(firstCDP).arg(lastCDP);
    To copy to clipboard, switch view to plain text mode 
    You can easily expand this for larger pieces of text.

  5. The following user says thank you to mitro for this useful post:

    jaca (6th May 2008)

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. QTableWidgetItem Text Editing
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 02:23
  3. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 14:36
  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.