[Qt-interest] Box Pick Zoom - Please Look at the code snippet help me to solve this

Sujan Dasmahapatra sujan.dasmahapatra at gmail.com
Sat Aug 15 14:07:19 CEST 2009


Dear Friends
If I reimplement paintEvent() method of QGraphicsView then all my previously
painted graphicsItems are going off from the screen

Actually like  this
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class GraphiscScene : public QGraphicsScene
{
   Q_OBJECT;
}
GraphiscScene::GraphicsScene()
{
   setBackgroundBrush(Qt::black);
}

class GraphicsView:public QGraphicsView
{
     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.
void GraphicsView::paintEvent(QPaintEvent *event)
{
}

class MainWindow:public QMainWindow
{
    Q_OBJECT
public:
     GraphicsView  *view;
    GraphicsScene *scene;
}

MainWindow::MainWindow()
{ox Pick Zoom
   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 ???
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090815/5643cc69/attachment.html 


More information about the Qt-interest-old mailing list