QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior
-
I have a function that is supposed to open a local media file.
in that I only have one line of code (below):
QDesktopServices::openUrl(QUrl::fromLocalFile("D:\\Desktop\\Test1\\ACID Explained - Atomic, Consistent, Isolated & Durable.mkv"));
When I call that function through a pushButton click for the first time after I open the app it works fine but from the second time on it stops working. I call it many times after the first time but only works randomly.
I am on Windows in MingW environment and I experienced this behavior with Qt 5.15.2, 6.1.2, 6.1.3 and 6.2.0.
Has anyone experienced something similar?
-
Hi,
Which application opens that file ?
Do you stop it between two calls ? -
@hbatalha said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:
I call it many times after the first time but only works randomly.
Sounds like Windows application behaviour on the app associated with
.mkv
, not to do with Qt. Is it possible that does nothing if that file/URL is already open? Check running processes to see if that app might already be running on that file? -
@mchinand said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:
In addition to @SGaist 's questions, what is the behavior when you double-click on the file in Windows File Explorer and then when you double-click on the file subsequent times?
It opens files normally as expected
-
@hbatalha said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:
It opens files normally as expected
What is the behavior when you click on the same file a second time when the application is still running from clicking on the file the first time?
-
@JonB said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:
Sounds like Windows application behaviour on the app associated with .mkv, not to do with Qt.
It looks like you are right, I just switched the default app for .mkv from VLC to Windows Movies & TV and it is opening file every time I call the function.
Check running processes to see if that app might already be running on that file?
No, no process is running on the file.
-
@mchinand said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:
@hbatalha said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:
It opens files normally as expected
What is the behavior when you click on the same file a second time when the application is still running from clicking on the file the first time?
It restarts the media.
-
@hbatalha said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:
Qt Widgets Application
Is it your own application ?
If so, I would say that it does not handle opening the file properly ?