Hey Guys,

I subclassed QGraphicsView and an QGraphicsPixmapItem...
What i want: I want to add a Pixmap to the GraphicsView and resize it (if the pixmap does not have it's desired maximum size) on resizing the GraphicsView..

What i receive: an unhandled exception in QPaintDevice:aintingActive()

Qt Code:
  1. inline bool QPaintDevice::paintingActive() const
  2. { return painters != 0; } // seems i get the exception here
To copy to clipboard, switch view to plain text mode 


Qt Code:
  1. BackgroundItem::BackgroundItem(const QPixmap &pixmap)
  2. {
  3. myOriginalPixmap = pixmap;
  4. }
  5.  
  6. QPixmap BackgroundItem::getOriginalPixmap(){
  7. return myOriginalPixmap;
  8. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. void FloorPlanGraphicsView::init()
  2. {
  3. canvas = new QGraphicsScene(this);
  4. //scene->setSceneRect(0,0,this->geometry().width(),this->geometry().height();
  5. setScene(canvas);
  6. setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
  7. }
  8.  
  9. void FloorPlanGraphicsView::setFloorPlan(const QPixmap &image){
  10. BackgroundItem *backImg = new BackgroundItem(image);//.scaled(geometry().width(),geometry().height(),Qt::KeepAspectRatio));
  11. scene()->addItem(backImg);
  12. backImg->setPos(0,0);
  13. backImg->setZValue(0);
  14. backImg->setPixmap(image.scaled(geometry().width(),geometry().height(),Qt::KeepAspectRatio));
  15. }
  16. void FloorPlanGraphicsView::resizeEvent(QResizeEvent *event){
  17. scene()->setSceneRect(0,0,this->geometry().width(),this->geometry().height());
  18.  
  19. QList<QGraphicsItem*> graphicItems = scene()->items();
  20. for (int i = 0; i < graphicItems.size(); ++i){
  21.  
  22. if (graphicItems.at(i)->type() == FloorPlanGraphicsView::BackgroundType){
  23. BackgroundItem *myBackItem = qgraphicsitem_cast<BackgroundItem*>(graphicItems.at(i));
  24.  
  25. if(this->geometry().width() <= myBackItem->getOriginalPixmap().size().width() && this->geometry().height() <= myBackItem->getOriginalPixmap().size().height())
  26. // i get the error immediately here on resize!
  27. myBackItem->setPixmap(myBackItem->getOriginalPixmap().scaled(this->geometry().width(),this->geometry().height(),Qt::KeepAspectRatio));
  28. else
  29. myBackItem->setPixmap(myBackItem->getOriginalPixmap());
  30. }
  31. }
  32. }
To copy to clipboard, switch view to plain text mode 

The invocation to setFloorPlan() looks like the following:
Qt Code:
  1. ui.floorPlan->setFloorPlan(QPixmap::fromImage(QImage::fromData(query.value(0).toByteArray())));
To copy to clipboard, switch view to plain text mode 

Do i have to reimplement a paint() function or something similar here?
Anbody any idea for me?