Results 1 to 7 of 7

Thread: Launching an application without display

  1. #1
    Join Date
    Nov 2007
    Posts
    36
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Launching an application without display

    Hello Qt Devs,

    I'm developing in Linux and trying to launch an application in a Linux server. The server doesn't have connected a monitor, so the environment variable "DISPLAY" is not defined.

    The application is requesting a DISPLAY, so I'm forced to define the variable although there isn't any display.

    Define DISPLAY is a solution, but I prefer to avoid that option.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Launching an application without display

    Don't link against QtGui (Add QT -= gui to your project file).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    tarod (2nd July 2012)

  4. #3
    Join Date
    Nov 2007
    Posts
    36
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Launching an application without display

    Thank you. I'm gonna try it.

  5. #4
    Join Date
    Nov 2007
    Posts
    36
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Launching an application without display

    A little story.

    Link or not against QtGui (adding QT -= gui to your project file) didn't work for me. The application requires the display anyway.

    The problem is that I use QApplication in my code, so the application needs a display or X server.

    I was testing QCoreApplication instead QApplication , but it is not suitable in my case because I'm using QPainter with drawText functions. Searching on the Internet we can found there is a bug when QCoreApplication and QPainter are used together.

    http://comments.gmane.org/gmane.comp....general/17392

    I don't know if the bug is solved nowadays. My Qt version is 4.2.3 (yep, old, but it's not my fault!)

    So, after reading the QApplication source code more thoroughly, changing this line:

    QApplication app(argc, argv);

    to this:

    QApplication app(argc, argv, false);

    The QApplication no longer complains about not finding an X server, and QPainter works well.

    Please, tell me you opinions about this issue.

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Launching an application without display

    If your application requires X11, then you need X11. You can upgrade to newer Qt that doesn't require X to use fonts.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #6
    Join Date
    Nov 2007
    Posts
    36
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Launching an application without display

    Well, X11 is already installed.

    Anyway, do you think QCoreApplication is also necessary in addition to "QT -= gui"?

  8. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Launching an application without display

    Anyway, do you think QCoreApplication is also necessary in addition to "QT -= gui"?
    if you don't need GUI facilities, then yes, use QCoreApplication instead of QApplication, and as wysota suggested, "QT -= gui"
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Replies: 0
    Last Post: 8th May 2012, 19:50
  2. How to display my application gui
    By thefatladysingsopera in forum Newbie
    Replies: 6
    Last Post: 28th July 2011, 15:24
  3. Replies: 3
    Last Post: 23rd February 2011, 12:03
  4. Launching GUI application on different X11 display
    By basy in forum Installation and Deployment
    Replies: 3
    Last Post: 3rd December 2010, 20:21
  5. Replies: 5
    Last Post: 15th June 2007, 22:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.