I guess you are using Raspbian Stretch
. This comes with systemd
so you should start your qt project as service. First create a new service:
rpi3 ~$ sudo systemctl edit --force --full my_qt_project.service
Insert this statements with your settings, save them and quit the editor:
[Unit]
Description=My Qt Project Service
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi
ExecStart=/home/pi/my_qt.project
[Install]
RequiredBy=graphical.target
# Look at the comments, maybe you can use
#WantedBy=graphical.target
Check the new service:
rpi3 ~$ systemctl status my_qt_project.service
● my_qt_project.service - My Qt Project Service
Loaded: loaded (/etc/systemd/system/my_qt_project.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Now you can enable and test your service:
rpi3 ~$ sudo systemctl enable my_qt_project.service
rpi3 ~$ sudo systemctl start my_qt_project.service
Here are some commands that may help. After editing you must restart the service to take effect.
rpi3 ~$ systemctl status my_qt_project.service
rpi3 ~$ systemctl cat my_qt_project.service
rpi3 ~$ sudo systemctl edit --full my_qt_project.service
rpi3 ~$ sudo systemctl restart my_qt_project.service
references
[1] man systemd.unit
[2] Running a script after an internet connection is established
[3] No access to USB port, when running python script on boot