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. Dynamic Path QFile
Forum Updated to NodeBB v4.3 + New Features

Dynamic Path QFile

Scheduled Pinned Locked Moved Solved General and Desktop
qfilepathfile
3 Posts 2 Posters 1.8k Views 2 Watching
  • 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.
  • cxamC Offline
    cxamC Offline
    cxam
    wrote on last edited by
    #1

    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.

    Stay Hungry, Stay Foolish

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      what is the question?

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

      or

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

      cxamC 1 Reply Last reply
      1
      • mrjjM mrjj

        what is the question?

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

        or

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

        cxamC Offline
        cxamC Offline
        cxam
        wrote on last edited by
        #3

        @mrjj said:

        "/home/pics/" + name"

        Indeed, it worked. Thank you :)

        Stay Hungry, Stay Foolish

        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