I need make scene contains another scenes.
Schema: MainWindow->MainView->MainScene->LittleWidget->LittleView->LittleScene
class LittleScene:public QGraphicsScene
{
public:
LittleScene(QObject* parent=nullptr):QGraphicsScene(parent){};
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event) override{}
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
{
//just to catch a function call
auto wi = new QWidget(this);
wi->show();
}
};
class LittleWidget:public QWidget
{
LittleScene *scene;
QGraphicsView *view;
public:
LittleWidget(QObject* parent):
scene(new LittleScene(parent)),
view(new QGraphicsView(scene))
{
auto lay=new QGridLayout(this);
lay->addWidget(view);
this->setLayout(lay);
this->resize(100,50);
}
//protected: //#1
// void mousePressEvent(QMouseEvent *event) override{}
};
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
auto scene = new QGraphicsScene;
ui->graphicsView->setScene(scene);
auto wid = scene->addWidget(new LittleWidget(scene),Qt::Window);
}
If compile this code mouseReleaseEvent()
has never been invoked for left button (with others there is no any problems).
If uncomment #1 - works perfectly.
I've tried with no parent-child relationship - the same behavior.
What a hell?
(Maybe it's already fixed bug - I'm using 5.10.1)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…