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

Thomas Dähling t.daehling at googlemail.com
Sat Aug 15 14:28:40 CEST 2009


Hi,

looks like I misunderstood your initial post on this issue, so I took 
another look at the documentation (which you should do as well, it is 
helpful and would have saved you quite some time!)

The documentation on QGraphicsView mentions the dragMode property to 
achieve what you want:
http://doc.trolltech.com/4.5/qgraphicsview.html#dragMode-prop

/Thomas

Sujan Dasmahapatra schrieb:
> 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 ???
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest



More information about the Qt-interest-old mailing list