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[])
{
scene.setSceneRect(0, 0, 1024, 768);
scene.
setBackgroundBrush(QColor::fromRgb(47,
51,
47));
gui view(&scene);
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setWindowFlags(Qt::FramelessWindowHint) ;
view.setFixedSize(1024, 768);
view.show();
return a.exec();
}
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::ScrollBarAlwaysOff);
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setWindowFlags(Qt::FramelessWindowHint) ;
view.setCacheMode(QGraphicsView::CacheBackground);
view.setDragMode(QGraphicsView::NoDrag);
view.setFixedSize(1024, 768);
view.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
And this doesn't work:
int main(int argc, char *argv[])
{
Starter s;
return a.exec();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Starter s;
return a.exec();
}
To copy to clipboard, switch view to plain text mode
{
Q_OBJECT
public:
Starter();
};
class Starter : public QObject
{
Q_OBJECT
public:
Starter();
};
To copy to clipboard, switch view to plain text mode
Starter::Starter()
{
s.setSceneRect(0, 0, 1024, 768);
s.
setBackgroundBrush(QColor::fromRgb(47,
51,
47));
gui view(&s);
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setWindowFlags(Qt::FramelessWindowHint) ;
view.setFixedSize(1024, 768);
view.show();
}
Starter::Starter()
{
QGraphicsScene s;
s.setSceneRect(0, 0, 1024, 768);
s.setBackgroundBrush(QColor::fromRgb(47, 51, 47));
gui view(&s);
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setWindowFlags(Qt::FramelessWindowHint) ;
view.setCacheMode(QGraphicsView::CacheBackground);
view.setDragMode(QGraphicsView::NoDrag);
view.setFixedSize(1024, 768);
view.show();
}
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.
Bookmarks