GraphicsView paintEvent() method implementation problem
Dear Friends
If I reimplement paintEvent() method of QGraphicsView then all my previously painted graphicsItems are going off from the screen
Actually like this
Code:
{
Q_OBJECT;
}
GraphiscScene::GraphicsScene()
{
setBackgroundBrush(Qt::black);
}
{
Q_OBJECT
public:
GraphicsView(GraphicsScene *Scene);
void paintEvent
(QPaintEvent *event
);
// if I add this part and implement it my screen is getting white. and no items are visible. }
GraphicsView::GraphicsView(GraphicsScene *Scene)
{
setScene(Scene);
}
// previously this was not there...Now I want to implement paintEvent to draw a rectangle on the screen.But if I add this part my screen is getting white.
{
}
{
Q_OBJECT
public:
GraphicsView *view;
GraphicsScene *scene;
}
MainWindow::MainWindow()
{
scene = new GraphicsScene;
view = new GraphicsView(scene);
view->show();
}
// After creating a view and scene like this I am creating some GraphicsItems and adding them to into the scene
// They're being displayed nicely on the screen
// Now I want to draw a dynamic rectangle starting from mousePree point to mouseRelease point and that iwant to draw on the screen
// For that I need to reimplement paintEvent() method of the GraphicsView
// But when I try to implement that my intial view which should be black screen is getting white and no items are visible in the view.
Can anyone tell what I am doing wrokng in thisi ???
Re: GraphicsView paintEvent() method implementation problem
Please, try to use code tags where possible.
Re: GraphicsView paintEvent() method implementation problem
Quote:
void paintEvent(QPaintEvent *event);
in case of using paintEvent on view u can use ..
this will help u painting on QGraphicsScene()