trallallero
28th October 2009, 14:21
I have a class derived from QGraphicsView that creates a GUI only if created by the main.
So, this works:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGraphicsScene scene;
scene.setSceneRect(0, 0, 1024, 768);
scene.setBackgroundBrush(QColor::fromRgb(47, 51, 47));
gui view(&scene);
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlw aysOff);
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlway sOff);
view.setWindowFlags(Qt::FramelessWindowHint) ;
view.setCacheMode(QGraphicsView::CacheBackground);
view.setDragMode(QGraphicsView::NoDrag);
view.setFixedSize(1024, 768);
view.show();
return a.exec();
}
And this doesn't work:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Starter s;
return a.exec();
}
class Starter : public QObject
{
Q_OBJECT
public:
Starter();
};
Starter::Starter()
{
QGraphicsScene s;
s.setSceneRect(0, 0, 1024, 768);
s.setBackgroundBrush(QColor::fromRgb(47, 51, 47));
gui view(&s);
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlw aysOff);
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlway sOff);
view.setWindowFlags(Qt::FramelessWindowHint) ;
view.setCacheMode(QGraphicsView::CacheBackground);
view.setDragMode(QGraphicsView::NoDrag);
view.setFixedSize(1024, 768);
view.show();
}
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.
So, this works:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGraphicsScene scene;
scene.setSceneRect(0, 0, 1024, 768);
scene.setBackgroundBrush(QColor::fromRgb(47, 51, 47));
gui view(&scene);
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlw aysOff);
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlway sOff);
view.setWindowFlags(Qt::FramelessWindowHint) ;
view.setCacheMode(QGraphicsView::CacheBackground);
view.setDragMode(QGraphicsView::NoDrag);
view.setFixedSize(1024, 768);
view.show();
return a.exec();
}
And this doesn't work:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Starter s;
return a.exec();
}
class Starter : public QObject
{
Q_OBJECT
public:
Starter();
};
Starter::Starter()
{
QGraphicsScene s;
s.setSceneRect(0, 0, 1024, 768);
s.setBackgroundBrush(QColor::fromRgb(47, 51, 47));
gui view(&s);
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlw aysOff);
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlway sOff);
view.setWindowFlags(Qt::FramelessWindowHint) ;
view.setCacheMode(QGraphicsView::CacheBackground);
view.setDragMode(QGraphicsView::NoDrag);
view.setFixedSize(1024, 768);
view.show();
}
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.