Hi,
I'm making a simple game the point is I want to put one scene on other scene. Both have the same size. First one will be a background with static and movable items, on second one will be an object which is movable. I order to do such thing I want to set second scene (with an object ) as transparent:
#include "widget.h"
#include "ui_widget.h"
#include "samolot.h"
ui(new Ui::Widget)
{
ui->setupUi(this);
ui->graphicsView->setBackgroundBrush(Qt::NoBrush);
scena_sam->setBackgroundBrush(Qt::NoBrush);
scena_sam->setSceneRect(0,0,200,200);
scena_tla->setBackgroundBrush(Qt::green);
scena_tla->setSceneRect(0,0,200,200);
ui->graphicsView->setScene(scena_tla);
ui->graphicsView->setScene(scena_sam);
samolot *sam = new samolot();
scena_sam->addItem(sam);
scena_sam->setFocusItem(sam, Qt::TabFocusReason);
}
Widget::~Widget()
{
delete ui;
}
#include "widget.h"
#include "ui_widget.h"
#include "samolot.h"
Widget::Widget(QWidget *parent) : QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
ui->graphicsView->setBackgroundBrush(Qt::NoBrush);
scena_tla = new QGraphicsScene(this);
scena_sam = new QGraphicsScene(this);
scena_sam->setBackgroundBrush(Qt::NoBrush);
scena_sam->setSceneRect(0,0,200,200);
scena_tla->setBackgroundBrush(Qt::green);
scena_tla->setSceneRect(0,0,200,200);
ui->graphicsView->setScene(scena_tla);
ui->graphicsView->setScene(scena_sam);
samolot *sam = new samolot();
scena_sam->addItem(sam);
scena_sam->setFocusItem(sam, Qt::TabFocusReason);
}
Widget::~Widget()
{
delete ui;
}
To copy to clipboard, switch view to plain text mode
unfortunately everything I try I faill. The problem is that second scene is alwals white even when I set
scena_sam->setBackgroundBrush(Qt::NoBrush);
scena_sam->setBackgroundBrush(Qt::NoBrush);
To copy to clipboard, switch view to plain text mode
or
scena_sam->setBackgroundBrush(Qt::transparent);
scena_sam->setBackgroundBrush(Qt::transparent);
To copy to clipboard, switch view to plain text mode
Maybe my whole concept is wrong, so I would be grateful for other ideas how to achieve this funcionality.
Thanks for any ideas
Bookmarks