Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. run qt application from other app and cron
QtWS25 Last Chance

run qt application from other app and cron

Scheduled Pinned Locked Moved Unsolved Qt for Python
9 Posts 4 Posters 617 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    common_user
    wrote on last edited by
    #1

    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 return

    qt.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 works

    Can't I run the qt program with another app or cron?

    JonBJ 1 Reply Last reply
    0
    • C common_user

      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 return

      qt.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 works

      Can't I run the qt program with another app or cron?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @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 a QCoreApplication can be instantiated (not QGuiApplication or QApplication).

      C 1 Reply Last reply
      1
      • JonBJ JonB

        @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 a QCoreApplication can be instantiated (not QGuiApplication or QApplication).

        C Offline
        C Offline
        common_user
        wrote on last edited by
        #3

        @JonB
        thanks you for reply.
        Then will it be the same if I register as a service?

        JonBJ 1 Reply Last reply
        0
        • C common_user

          @JonB
          thanks you for reply.
          Then will it be the same if I register as a service?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @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?

          C 1 Reply Last reply
          1
          • JonBJ JonB

            @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?

            C Offline
            C Offline
            common_user
            wrote on last edited by
            #5

            @JonB
            I want the program to turn on automatically
            It's kind of a kiosk program for personal

            jsulmJ 1 Reply Last reply
            0
            • C common_user

              @JonB
              I want the program to turn on automatically
              It's kind of a kiosk program for personal

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @common_user What desktop environment or window manager do you use?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              C 1 Reply Last reply
              0
              • jsulmJ jsulm

                @common_user What desktop environment or window manager do you use?

                C Offline
                C Offline
                common_user
                wrote on last edited by
                #7

                @jsulm
                ubuntu 22.04

                jsulmJ 1 Reply Last reply
                0
                • C common_user

                  @jsulm
                  ubuntu 22.04

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by jsulm
                  #8

                  @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

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    friedemannkleint
                    wrote on last edited by
                    #9

                    You can run [binary] -platform offscreen (unsupported) to run a GUI app headless without any Desktop environment. Not sure that is intended here, though.

                    1 Reply Last reply
                    2

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved