Guest User

Untitled

a guest
Jun 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. class ViewerScene : public QGraphicsScene
  2. {
  3. Q_OBJECT
  4. public:
  5. ViewerScene(QWidget* parent = 0, const char* name = 0);
  6. void setBackgroundPixmap(const QPixmap& pixmap);
  7. void setRect(const QRect& rect);
  8. void getRect(QRect& rect);
  9.  
  10. protected:
  11. virtual void drawBackground(QPainter* painter, const QRectF& rect);
  12.  
  13. private:
  14. QPixmap m_backgroundPixmap;
  15. QRect m_rect;
  16.  
  17. void ViewerScene::drawBackground(QPainter* painter, const QRectF & rect)
  18. {
  19. QRect sourceRect(0, 0, m_backgroundPixmap.width(),
  20. m_backgroundPixmap.height());
  21. painter->drawPixmap(m_rect, m_backgroundPixmap, sourceRect);
  22. QGraphicsScene::drawBackground(painter, rect);
  23. }
  24.  
  25. QRect r;
  26. scene->getRect(r);
  27. QPoint p = your_QGraphicsView->mapFromScene(r.topLeft());
  28. qDebug() << p;
Add Comment
Please, Sign In to add comment