run qt application from other app and cron
-
I'm going to create a qt program with Python and run it.
It works fine when execute "sudo ./program" on Ubuntu's terminal, but when I try to run the program on cron or another application, it returnqt.qpa.xcb: could not connect to display :0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
I've already used export DISPLAY=:0
but it doesn't worksCan't I run the qt program with another app or cron?
-
I'm going to create a qt program with Python and run it.
It works fine when execute "sudo ./program" on Ubuntu's terminal, but when I try to run the program on cron or another application, it returnqt.qpa.xcb: could not connect to display :0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
I've already used export DISPLAY=:0
but it doesn't worksCan't I run the qt program with another app or cron?
@common_user
Since cron is a "background/batch" system, you cannot run an application which requires a UI, tries to connect to a display or similar. Clearly your Qt application does require a UI so is not suitable. Write your application to not require GUI or Widgets, i.e. no more than aQCoreApplication
can be instantiated (notQGuiApplication
orQApplication
). -
@common_user
Since cron is a "background/batch" system, you cannot run an application which requires a UI, tries to connect to a display or similar. Clearly your Qt application does require a UI so is not suitable. Write your application to not require GUI or Widgets, i.e. no more than aQCoreApplication
can be instantiated (notQGuiApplication
orQApplication
).@JonB
thanks you for reply.
Then will it be the same if I register as a service? -
@JonB
thanks you for reply.
Then will it be the same if I register as a service?@common_user
Depending on what you mean by "a service", yes I imagine so. How would either cron or services have any access to any UI, since the whole point is they run unattended in the background? More to the point, if you are wanting to run your application like this how/why would you want anything which requires any access to a UI? -
@common_user
Depending on what you mean by "a service", yes I imagine so. How would either cron or services have any access to any UI, since the whole point is they run unattended in the background? More to the point, if you are wanting to run your application like this how/why would you want anything which requires any access to a UI?@JonB
I want the program to turn on automatically
It's kind of a kiosk program for personal -
@JonB
I want the program to turn on automatically
It's kind of a kiosk program for personal@common_user What desktop environment or window manager do you use?
-
@common_user What desktop environment or window manager do you use?
@jsulm
ubuntu 22.04 -
@jsulm
ubuntu 22.04@common_user This is not what I asked
But if you're using standard Ubuntu then take a look at https://help.ubuntu.com/stable/ubuntu-help/startup-applications.html.en -
You can run [binary] -platform offscreen (unsupported) to run a GUI app headless without any Desktop environment. Not sure that is intended here, though.