-1

I want to make my qt project run while booting raspberry pi3. When I searched on the web there is a solution for python. Eventhough I put some code on rc.local, this did not solve my problem.

The application has a GUI and the OS is Raspbian Stretch.

goldilocks
  • 60,325
  • 17
  • 117
  • 234
aysenur
  • 1
  • 1
  • 1

2 Answers2

3

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

Ingo
  • 42,961
  • 20
  • 87
  • 207
0

Thank you for your answers. Adding the execution path of the application with sudo command ( @sudo /path/to/QtPro ) to the following file solved the problem. ~/.config/lxsession/LXDE-pi/autostart

aysenur
  • 1
  • 1
  • 1