[Qt-interest] how to convert QMap<QString, QString>::const_iterator to QString?

Werner Van Belle werner at yellowcouch.org
Mon Apr 5 19:17:25 CEST 2010


Ross Driedger wrote:
> On 5-Apr-10, at 6:49 AM, qt-interest-request at trolltech.com
> <mailto:qt-interest-request at trolltech.com> wrote:
>> QMap<QString,QString> args
>> QMap<QString,QString>::const_iterator i = args.constBegin();
>>    while (i != args.constEnd()) {
>>       //cout << i.key() << ": " << i.value() << endl;
>>        QString temp(i.key().toStdString()  +  ": "  +
>> i.value().toStdString());  // this dosn't work !!!
>
> Why would you convert a QString to std::string object and then back to
> QString? 
I could utter a couple of guesses:

a- You have two libraries: one using strings the other QStrings. You
need to pass data from one to the other and back.
b- You have a large chunk of code you wrote yourself and you don't
_want_ to modify everything you wrote to fit with QStrings. Instead, you
want the user interface in its own module and you want to keep it there.
For instance, you also have a GTK UI.

> QString is perfectly capable of doing the job itself, so there is no
reason to switch from one to the other and back.

I'm sure it is, but honoustly. The argument: 'why don't you use QString'
is not really answering the question, and personally I can perfectly
understand why somebody might want something else but a QString. The
last Qt3->4 convertion I got stuck with was a nightmare, and this
despite the fact that we used QStrings in the first place. If we had
used something else but QStrings, our entire transition might have been
a lot simpler.

Wkr,

-- 
http://werner.yellowcouch.org/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100405/b9a96798/attachment.bin 


More information about the Qt-interest-old mailing list