Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Enabling Qt Widgets application to run with no gui capability (e. g. SSH) on Linux

Enabling Qt Widgets application to run with no gui capability (e. g. SSH) on Linux

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 921 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.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on 9 Nov 2023, 19:37 last edited by
    #1

    When I run my Qt 6 widgets application in an SSH session on Linux, I get the following errors, and it doesn't run:

    qt.qpa.xcb: could not connect to display
    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: offscreen, linuxfb, xcb, vnc, minimalegl, vkkhrdisplay, eglfs, minimal.
    

    I know that obviously the GUI will not display or even run, and nothing GUI-related will work. That's fine. I would like to gracefully ignore this error and still run the app. If I know which condition to check, I may avoid calling app.exec() if that's a problem. Or, perhaps, there is a way to use another plugin, like minimal, as a stub to let the application work?

    In the worst case, I could check whether or not GUI is available and conditionally create either QCoreApplication or QApplication. But I don't know how to write the check, any ideas?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 9 Nov 2023, 19:44 last edited by
      #2

      Hi,

      If your remote machine has Xorg, you could enable X11 forwarding for your SSH connection.

      Otherwise, you can use the offscreen plugin.

      As for the availability check, it's possible but I currently don't remember how to implement it.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      V 1 Reply Last reply 9 Nov 2023, 20:01
      1
      • S SGaist
        9 Nov 2023, 19:44

        Hi,

        If your remote machine has Xorg, you could enable X11 forwarding for your SSH connection.

        Otherwise, you can use the offscreen plugin.

        As for the availability check, it's possible but I currently don't remember how to implement it.

        V Offline
        V Offline
        Violet Giraffe
        wrote on 9 Nov 2023, 20:01 last edited by
        #3

        @SGaist, thank you!
        I don't need forwarding, I just need Qt to ignore the problem. Ideally, a "no-op" plugin, so that no CPU cycles are wasted rendering off-screen either. How can I select a non-default plugin?

        And still, if I'm going to select it manually I do need to know whether or not I have the GUI capability. Please let me know if you remember the check - I tried googling, but nothing yet. Will give it another try.

        S 1 Reply Last reply 9 Nov 2023, 20:14
        0
        • V Violet Giraffe
          9 Nov 2023, 20:01

          @SGaist, thank you!
          I don't need forwarding, I just need Qt to ignore the problem. Ideally, a "no-op" plugin, so that no CPU cycles are wasted rendering off-screen either. How can I select a non-default plugin?

          And still, if I'm going to select it manually I do need to know whether or not I have the GUI capability. Please let me know if you remember the check - I tried googling, but nothing yet. Will give it another try.

          S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 9 Nov 2023, 20:14 last edited by
          #4

          You can use the QT_QPA_PLATFORM environment variable.

          You can check this answer on the forum for inspiration.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • S Offline
            S Offline
            SimonSchroeder
            wrote on 15 Nov 2023, 07:40 last edited by
            #5

            Would it be sufficient for you to provide a command line option to turn off the GUI? In addition – not sure if would work – you could register your own function with atexit (is in the C standard) that prints a help message that you could try running with your parameter for no-GUI (which hopefully shows up after the error message from Qt).

            On Linux it could also help to check if the DISPLAY environment variable is set. This is not the case (by default) for SSH connections without X forwarding.

            V 1 Reply Last reply 15 Nov 2023, 14:41
            2
            • S SimonSchroeder
              15 Nov 2023, 07:40

              Would it be sufficient for you to provide a command line option to turn off the GUI? In addition – not sure if would work – you could register your own function with atexit (is in the C standard) that prints a help message that you could try running with your parameter for no-GUI (which hopefully shows up after the error message from Qt).

              On Linux it could also help to check if the DISPLAY environment variable is set. This is not the case (by default) for SSH connections without X forwarding.

              V Offline
              V Offline
              Violet Giraffe
              wrote on 15 Nov 2023, 14:41 last edited by
              #6

              Good suggestions, thanks!

              1 Reply Last reply
              0

              4/6

              9 Nov 2023, 20:14

              • Login

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