Unsolved How do I get the complete file path of the file selected by the user
-
This post is deleted! -
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.
-
@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);
} -
@wizzyrider
So what is the question? -
@JonB i want to get the url of the resource file that the user selected from the list of files
-
-
Do you want to tell us what your
file.absolutePath()
produced, or leave us to guess? -
It's presumably
:/entertainment /files
followed byfile.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?
-
-
-
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
-
-
@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()