I have a class derived from QGraphicsView that creates a GUI only if created by the main.
So, this works:
Qt Code:
  1. int main(int argc, char *argv[])
  2. {
  3. QApplication a(argc, argv);
  4.  
  5. scene.setSceneRect(0, 0, 1024, 768);
  6. scene.setBackgroundBrush(QColor::fromRgb(47, 51, 47));
  7.  
  8. gui view(&scene);
  9. view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  10. view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  11. view.setWindowFlags(Qt::FramelessWindowHint) ;
  12. view.setCacheMode(QGraphicsView::CacheBackground);
  13. view.setDragMode(QGraphicsView::NoDrag);
  14. view.setFixedSize(1024, 768);
  15. view.show();
  16.  
  17. return a.exec();
  18. }
To copy to clipboard, switch view to plain text mode 

And this doesn't work:

Qt Code:
  1. int main(int argc, char *argv[])
  2. {
  3. QApplication a(argc, argv);
  4. Starter s;
  5. return a.exec();
  6. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. class Starter : public QObject
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. Starter();
  7. };
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. Starter::Starter()
  2. {
  3. s.setSceneRect(0, 0, 1024, 768);
  4. s.setBackgroundBrush(QColor::fromRgb(47, 51, 47));
  5.  
  6. gui view(&s);
  7.  
  8. view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  9. view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  10. view.setWindowFlags(Qt::FramelessWindowHint) ;
  11. view.setCacheMode(QGraphicsView::CacheBackground);
  12. view.setDragMode(QGraphicsView::NoDrag);
  13. view.setFixedSize(1024, 768);
  14. view.show();
  15. }
To copy to clipboard, switch view to plain text mode 

Why ?

The main problem is that I need a GUI with an empty constructor as my main application will load a plugin (the GUI) that will create a GUI based on a QGraphicsScene.
So the Starter could create the QGraphicsScene and pass it to the gui class, but it doesn't work.