Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved] Converting string to QString

[solved] Converting string to QString

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abich
    wrote on last edited by
    #1

    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);
    .....@

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ankursaxena
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • A Offline
        A Offline
        abich
        wrote on last edited by
        #3

        Thanks it helps a lot

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved