Search code examples
c++qtqstringqvariant

How can I convert QVariant to QString and vice versa in Qt?


How can I convert QVariant to QString and Vice versa?

Thanks


Solution

  • From string:

    QString qs;
    QVariant qv(qs);
    

    To string:

    QString qs = qv.toString();
    

    Tip: reading the help helps.