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.
  • C Offline
    C Offline
    cxam
    wrote on 4 Apr 2016, 20:08 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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 4 Apr 2016, 20:48 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.

      C 1 Reply Last reply 4 Apr 2016, 21:01
      1
      • M mrjj
        4 Apr 2016, 20:48

        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.

        C Offline
        C Offline
        cxam
        wrote on 4 Apr 2016, 21:01 last edited by
        #3

        @mrjj said:

        "/home/pics/" + name"

        Indeed, it worked. Thank you :)

        Stay Hungry, Stay Foolish

        1 Reply Last reply
        0

        1/3

        4 Apr 2016, 20:08

        • Login

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