Search code examples
qtqgraphicsview

can i use 2 setScene on graphicsView?


i use this code but graphicsView will show the last command, how can i show two setScence in one graphicsView?

ui->setupUi(this);
line1= new QGraphicsScene (this);
line= new QGraphicsScene (this);

ui->graphicsView->setScene(line);    // not show
ui->graphicsView->setScene(line1);   // show

Solution

  • You need two QGraphicsViews. QGraphicsView can only show one scene at a time. I'm not sure it would make sense any other way. Perhaps you can look to QLayout or QSplitter if you want the two scenes/views side-by-side.