Reputation: 11
I am creating an GUI application using QT creater in Raspbian. When I click a button I want to open an external application like terminal, or browser, etc.
I have tried many attempts
std::system("/usr/share/raspi-ui-overrides/applications/scratch.desktop&");
it says me permission denied
QDesktopServices::openUrl(QUrl("/usr/share/raspi-ui-overrides/applications/scratch.desktop"));
QDesktopServices::openUrl(QUrl("/usr/share/raspi-ui-overrides/applications/scratch.desktop"));
Upvotes: 1
Views: 470
Reputation: 244023
The .desktop files are not executable, but serve as shortcuts for the desktop system. Assuming that the scratch.desktop has the following:
scratch.desktop
[Desktop Entry]
Name=Scratch
Comment= Programming system and content development tool
Exec=scratch
Terminal=false
Type=Application
Icon=scratch
Categories=Development;
MimeType=application/x-scratch-project
Then the executable is /usr/bin/scratch
, And you can run it with Qt:
QProcess::startDetached("/usr/bin/scratch");
Or:
QProcess::execute("/usr/bin/scratch");
Upvotes: 1
Reputation: 3608
I'm assuming the question is about Raspberry Pi and Raspbian.
In Raspbian, the scratch.desktop
and other *.desktop
files are not executables, but just text files that describe which application to run.
Example:
pi@raspberrypi:~ $ cat /usr/share/raspi-ui-overrides/applications/scratch.desktop
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
TryExec=scratch
Exec=scratch
Icon=scratch
Terminal=false
Name=Scratch
Comment= Programming system and content development tool
Categories=Application;Development;
MimeType=application/x-scratch-project
You need to use an actual binary to start the process. For scratch
, it would be /usr/bin/scratch
. For a browser, it's likely to be /usr/bin/epiphany-browser
. Look at Exec=
line in the *.desktop
file to see the name of the executable, then use which
in the terminal to see its location:
pi@raspberrypi:~ $ which epiphany-browser
/usr/bin/epiphany-browser
Upvotes: 1