Results 1 to 2 of 2

Thread: QString help

  1. #1
    Join Date
    Apr 2008
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QString help

    I want to concatenate two strings together and have the text appear as one line. Not sure when this doesn't work. Please help. Thanks!

    Code Example:
    if (strCommands.at(i).startsWith("step number:",Qt::CaseInsensitive))
    {
    stepNumberText = strCommands.at(i).trimmed();
    }
    else
    {
    actionText = strCommands.at(i).trimmed();
    uaTotal++;
    }

    lineText = stepNumberText.simplified() + " -- " + actionText.simplified()
    std::cout << lineText.toStdString() << std::endl;

    Output:
    step number: 2 --
    -- User Action: "Do Something"
    step number: 3 --
    -- User Verify: "Do Something else"
    step number: 4 --
    -- User Action: "Do this"
    -- User Action: "do it again"

  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: QString help

    Try this:

    Qt Code:
    1. #include <QtDebug>
    2. qDebug() << stepNumberText.simplified() << actionText.simplified();
    To copy to clipboard, switch view to plain text mode 
    And see if the output is in a single line. If it's not, you have some newlines somewhere.

Similar Threads

  1. easiest Way QString can do
    By baray98 in forum Qt Programming
    Replies: 12
    Last Post: 15th April 2008, 20:49
  2. QString static callback function from CURL
    By tpf80 in forum Qt Programming
    Replies: 12
    Last Post: 16th May 2007, 20:47
  3. Problem in converting QString to QChar array?
    By KaKa in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2007, 00:38
  4. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59
  5. QSqlQueryModel + set Write
    By raphaelf in forum Qt Programming
    Replies: 7
    Last Post: 5th June 2006, 08:55

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.