Creating an object of QGraphicsScene results in segmentation fault
I created a new Qt 5 project with QtCreator, and added the following lines to it.
#include <QGraphicsScene>
// in main():
QGraphicsScene scene;
In the .pro file I added:
Qt += gui
The object creation of QGraphicsScene is resulting in the segmentation fault. What point am I missing?
Re: Creating an object of QGraphicsScene results in segmentation fault
This works without issue Qt 5.2, GCC 4.7 on Linux:
Code:
#include <QApplication>
#include <QGraphicsScene>
int main(int argc, char **argv) {
return 0;
}
The QApplication must exist before the scene or it seg faults here too.
Re: Creating an object of QGraphicsScene results in segmentation fault
Thanks for respondng.
I realized now that instead of QApplication my rest of the program is using QtGui/QGuiApplication.
How to use QGraphicsScene with QtGui/QGuiApplication?
Re: Creating an object of QGraphicsScene results in segmentation fault
You can't. QGraphicsScene is part of QtWidgets and intimately connected to a full QApplication instance.
Re: Creating an object of QGraphicsScene results in segmentation fault
And you will also need
to add the widget library
Cheers,
_