Qt World Summit: Submit your Presentation

Dynamic Path QFile

  • Hi!
    I'm doing a function in which a program selects a picture from a file using a variable given by a String for example

    QString name = "carlos" + ".png";
    // (the first part of the string is given by a QLineEdit introduced by the user)
    QFile File("/home/pics/name")

    Thanks in advance.

  • Lifetime Qt Champion

    what is the question?

    QString name = "carlos" + ".png";
    QFile File("/home/pics/" + name");


    QFile File( qApp->applicationDirPath() +"/"+ name");
    to load it from folder where .exe is.
    This is good for deployment time.

  • @mrjj said:

    "/home/pics/" + name"

    Indeed, it worked. Thank you :)

Log in to reply