0

Is it possible to create an OpenGL context with Qt without creating anything of the windowing system (e.g. QWindow)?

I want to write an command line tool which uses OpenGL and Qt 5.1, and I currently create a context with QOpenGLContext and QWindow. I do not open the window, but the application still opens up in the Dock of OS X.

maxj
  • 45
  • 4

1 Answers1

0

Using Qt without the GUI

Qt can be used without the GUI. To create a window to show a OpenGL window without QWindow, you will need to change your .pro file to not include the gui modules, and then tell it to include the console.

QT -= gui # Only the core module is used.
CONFIG += console 

How do I create a simple Qt console application in C++?

While you are debugging from Qt Creator, you may need to go to the Project > Run and tell it to Run in Terminal, otherwise it might only exist in the application output area.

http://qt-project.org/doc/qt-5.1/qmake/qmake-project-files.html#declaring-qt-libraries

You will probably need to find some other windowing framework to display your opengl goodness. Depending on what examples you look at, sometimes they use glut, or opencv.

I'm not sure how closely tied the opengl libs are to the QWindow and the other QtGUI or QtWidgets internals. You may need to get opengl from another library if they aren't loading after you remove the Qt GUI.

LIBS += -lopengl #or some other things to use the library from somewhere else

Hope that helps.

Community
  • 1
  • 1
phyatt
  • 18,472
  • 5
  • 61
  • 80