Results 1 to 7 of 7

Thread: Function to convert std::string to QString

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Function to convert std::string to QString

    ...cos I want the QString to be return as long as i is less then...
    I understand that... but i told you that is not what happens (and it didn't even convert anything to QString)

    And assuming that would be possible (it is not) how would you "catch" the returned values - if you call a function once and then it returns a variable number of values?

    Ok, now, you can do a function that takes by reference a std::list<std::string> (it can be any container std::list is just an example) and add a QString to the QStringList for each value in the first list.

    LE:
    you can read more about recursion, if you want, because you have some confusion about it, and use the debugger to see exactly what it happening - you will understand that and you will improve debugging skills

  2. #2
    Join Date
    Apr 2011
    Posts
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Function to convert std::string to QString

    yeah I understand also that it is not possible the way I did it, thats why I'm asking for help.

    So you mean that my first function doesn't work at all? bcs if I call that function wiht ui->list2->addItem(d1.toQString());
    the info on dh[0] will be show as a big QString.
    So it is not possible to write a function that will go through my array and every time present the info from a certain slot?

    And yeah my recursion knowledge is very limited.

Similar Threads

  1. How to convert from QString to string ?
    By probine in forum Newbie
    Replies: 2
    Last Post: 1st December 2010, 01:50
  2. Replies: 8
    Last Post: 25th November 2010, 11:40
  3. How to convert string into const int ?
    By babygal in forum Qt Programming
    Replies: 3
    Last Post: 16th July 2010, 10:57
  4. How to convert QString to std::string or char*?
    By yangyunzhao in forum Qt Programming
    Replies: 26
    Last Post: 26th August 2009, 06:52
  5. convert a string to hex
    By priceey in forum Qt Programming
    Replies: 7
    Last Post: 12th February 2009, 10:38

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.