Abhishek
Abhishek

Reputation: 388

Convert QVector<char*> list into a QStringList

How can I convert a QVector<char*> to a QStringList?

Upvotes: 3

Views: 7944

Answers (2)

Angie Quijano
Angie Quijano

Reputation: 4453

I think you can try do it in this way (it works for me if I have a QVector<QString>):

QVector<char*> vector_char;
QStringList myStringList = vector_char.toList();

This code has to work as QStringList has inherited members of QList.

Here is somenthing in the documentation: QVector documentation.

And that is all. I hope it can help you.

Upvotes: 1

cmannett85
cmannett85

Reputation: 22346

There is no direct way.

QVector<char*> vector;
QStringList list;
foreach (const char * str, vector) {
    list << str;
}

Upvotes: 1

Related Questions