i have a simple media player and one of the features is that the player has a list of the videos that are opened , i want to create an additional feature where it checks wether the video or "file" has already been opened and stop it from opening i have tried something like this but it didnt work :
bool fileExists(QString path)= QFileInfo::exists(path).isFile();
if (fileExists(path)== true)
{
qDebug() <<"file already exists";
}
this here makes no sense:
bool fileExists(QString path)= QFileInfo::exists(path).isFile();
my suggestion to you is to define a method instead:
bool MainWindow::fileExists(QString path)
{
QFileInfo fi(path);
return fi.exists(path) && fi.isFile();
}
and for using it:
QString path{"/myPathToFile/myVideo.mp4"};
if (fileExists(path))
{
qDebug() << "file already exists";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.