Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use QGraphicsScene in console application?

according to the Qt specification QGraphicsScene is a viewless data model of QGraphicsItems. I have a tool which can be used in windowed and in non-windowed mode (when providing commandline arguments to it). In non windowed mode it should run as a console application (e.g. not connecting to X or so). However either I use the application as a QCoreApplication (qt5) or I set the guienabled flag (qt4) to false in QApplication my application (obviously?) crashes when trying to instantiate the QGraphicsScene object.

Any idea how to use QGraphicsScene in a console application (apart from "no, you can't")? Thanks,

like image 553
harsszegi Avatar asked Feb 05 '15 07:02

harsszegi


1 Answers

If anybody is interested in it, there is a solution in Qt5. Just put this before instantiating QApplication

qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("minimal"));

like image 155
harsszegi Avatar answered Oct 05 '22 06:10

harsszegi