[solved] Converting string to QString



  • How can i convert a string to a QString?? is it possible?
    In fact my program ask the user to write the name of an xml file, and to be parsed this name must be converted to a QString an use it to open a QFile.

    This is the code i tried but it doesn't work.
    @char* fn;
    QDomDocument doc;
    QString sfn;
    std::cout<<"please choose an xml file name"<<std::endl;
    cin>>fn;
    sfn=sfn.fromUtf8(fn,-1);
    QFile f(sfn);
    if (!(f.exists())) cout<<"The file does not exist"<<endl;
    op= f.open(QIODevice::ReadOnly);
    sc= doc.setContent(&f);
    .....@



  • QString str = QString::fromUtf8(content.c_str());



  • Thanks it helps a lot


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.