Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to set background for qgraphicsscene ?
happyRoll last edited by happyRoll
I used Qt's GrpahicsFrame to made an application of graffiti board. In addition, I want to set background for graphicsscene by QGaphicsScene::drawPixmap(const Qpixmap &pixmap) , it's right, but now this graffiti board is no respond for my mouse, I can't draw some lines on the board. The reason why I want to set a background is hope that I can draw better based on this picture.
if you know any other ways or suggestons, please tell me.
happyRoll last edited by
scene = new QGraphicsScene(20, 115, 600, 600,this);
canvas = new CanvasItem(this);
graphicsView = new QGraphicsView(this); graphicsView->setObjectName(QStringLiteral("graphicsView")); graphicsView->setGeometry(QRect(20, 115, 600, 600)); graphicsView->setMouseTracking(true); graphicsView->setScene(scene); QSizePolicy sizePolicy0 (QSizePolicy::Fixed, QSizePolicy::Fixed); sizePolicy0.setHorizontalStretch(0); sizePolicy0.setVerticalStretch(0); graphicsView->setSizePolicy(sizePolicy0); graphicsView->setFrameStyle(QFrame::Panel | QFrame::Raised); [QGraphicsView with QPixMap Background](https://forum.qt.io/topic/6313/qgraphicsview-with-qpixmap-background/4)
According this post, I use QgraphicsView::setStyleSheet() to set background, It‘s still useless.
but I comment this statement which "scene->addItem(canvas);", It's work.
//class CanvasItem :public QObject, public QGraphicsItem