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. Crash in QGuiApplication::font but..
Forum Updated to NodeBB v4.3 + New Features

Crash in QGuiApplication::font but..

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 2.3k Views 1 Watching
  • 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.
  • J Offline
    J Offline
    jmorris_nv
    wrote on last edited by
    #1

    I've upgraded a server I'm running to Ubuntu Server 20.04. Another goal of the upgrade was moving my software from Qt 4.x to 5.x

    The server is basically headless (definitely no desktop environment)

    The server receives images from other sources. One program loads the images into a QImage and paints on them using a QPainter adding a label to the modified images.

    Previously when I was using Qt 4.x and I was able to use QApplication with the "No GUI" flag, and everything "Just worked"

    The same program compiles just fine with Qt 5.x, after changing to QCoreApplication, but that results in a segfault when trying to use fonts (in QGuiApplication::font)

    If I use QGuiApplication, I get the following:

    "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: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb."

    Do I need to stick with Qt 4.x for this one program? Any other work arounds? Can I install one of those plugins without a desktop environment?

    Regards,

    John

    JKSHJ 1 Reply Last reply
    0
    • J jmorris_nv

      I've upgraded a server I'm running to Ubuntu Server 20.04. Another goal of the upgrade was moving my software from Qt 4.x to 5.x

      The server is basically headless (definitely no desktop environment)

      The server receives images from other sources. One program loads the images into a QImage and paints on them using a QPainter adding a label to the modified images.

      Previously when I was using Qt 4.x and I was able to use QApplication with the "No GUI" flag, and everything "Just worked"

      The same program compiles just fine with Qt 5.x, after changing to QCoreApplication, but that results in a segfault when trying to use fonts (in QGuiApplication::font)

      If I use QGuiApplication, I get the following:

      "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: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb."

      Do I need to stick with Qt 4.x for this one program? Any other work arounds? Can I install one of those plugins without a desktop environment?

      Regards,

      John

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @jmorris_nv said in Crash in QGuiApplication::font but..:

      "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: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb."

      Do I need to stick with Qt 4.x for this one program? Any other work arounds? Can I install one of those plugins without a desktop environment?

      You can tell your app to use the offscreen plugin instead of the xcb plugin by passing the -platform flag from the console:

      ./myapp -platform offscreen

      Previously when I was using Qt 4.x and I was able to use QApplication with the "No GUI" flag, and everything "Just worked"
      The same program compiles just fine with Qt 5.x, after changing to QCoreApplication, but that results in a segfault when trying to use fonts (in QGuiApplication::font)

      It segfaults because QCoreApplication::font() does not exist. You must use QGuiApplication or QApplication.

      Make sure your qApp pointer isn't getting cast to the wrong class. I believe that if you remove all instances of #include <QApplication> or #include <QGuiApplication> from your code, it will stop compiling.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      1
      • J Offline
        J Offline
        jmorris_nv
        wrote on last edited by
        #3

        After some quick testing, looks like "--platform offscreen" did the trick.

        Many thanks!

        1 Reply Last reply
        0

        • Login

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