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. How do I get the complete file path of the file selected by the user
Forum Updated to NodeBB v4.3 + New Features

How do I get the complete file path of the file selected by the user

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 945 Views 1 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.
  • W Offline
    W Offline
    wizzyrider
    wrote on last edited by
    #1
    This post is deleted!
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      I already asked you on stackoverflow - when you fill the list you should know where you get it from / what's the path where they're coming from - so add it afterwards again.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      W 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        I already asked you on stackoverflow - when you fill the list you should know where you get it from / what's the path where they're coming from - so add it afterwards again.

        W Offline
        W Offline
        wizzyrider
        wrote on last edited by
        #3

        @Christian-Ehrlicher yea the list shows the files in a specific resource file, this is the code for the list

        QDir dir(":/entertainment /files");
        for (const QFileInfo &file : dir.entryInfoList(QDir::Files))
        {
        QListWidgetItem *item = new QListWidgetItem(file.fileName());
        item->setData(Qt::UserRole, file.absolutePath());
        item->setIcon(QIcon(":/img/images/video.png"));
        ui->entertain->addItem(item);
        }

        JonBJ 1 Reply Last reply
        0
        • W wizzyrider

          @Christian-Ehrlicher yea the list shows the files in a specific resource file, this is the code for the list

          QDir dir(":/entertainment /files");
          for (const QFileInfo &file : dir.entryInfoList(QDir::Files))
          {
          QListWidgetItem *item = new QListWidgetItem(file.fileName());
          item->setData(Qt::UserRole, file.absolutePath());
          item->setIcon(QIcon(":/img/images/video.png"));
          ui->entertain->addItem(item);
          }

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @wizzyrider
          So what is the question?

          W 1 Reply Last reply
          0
          • JonBJ JonB

            @wizzyrider
            So what is the question?

            W Offline
            W Offline
            wizzyrider
            wrote on last edited by
            #5

            @JonB i want to get the url of the resource file that the user selected from the list of files

            JonBJ 1 Reply Last reply
            0
            • W wizzyrider

              @JonB i want to get the url of the resource file that the user selected from the list of files

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @wizzyrider

              • Do you want to tell us what your file.absolutePath() produced, or leave us to guess?

              • It's presumably :/entertainment /files followed by file.fileName() that you want, no? [EDIT: Since I copied & pasted your code, I notice you have a space in that literal path: I doubt that is correct?]

              • What do you think you are going to do with a URL that points into a resource file?

              W 1 Reply Last reply
              0
              • JonBJ JonB

                @wizzyrider

                • Do you want to tell us what your file.absolutePath() produced, or leave us to guess?

                • It's presumably :/entertainment /files followed by file.fileName() that you want, no? [EDIT: Since I copied & pasted your code, I notice you have a space in that literal path: I doubt that is correct?]

                • What do you think you are going to do with a URL that points into a resource file?

                W Offline
                W Offline
                wizzyrider
                wrote on last edited by
                #7

                @JonB

                • The file.absolutepath gives me the file path of the project file location and it is not what i want just something i tried to get what i want

                • I am developing a media player, i want to get the url so that i can use that url to direct the media player to that location to play the video

                I am sorry if i am not clear with my question I am new to Qt and doesn't have much experience with it

                1 Reply Last reply
                0
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @wizzyrider said in How do I get the complete file path of the file selected by the user:

                  and it is not what i want just something i tried to get what i want

                  Please re-read this and try to understand yourself what you want and what you want to tell us with this.

                  i want to get the url so that

                  Which media player?
                  See QUrl::fromLocalFile()

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  2

                  • Login

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