Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ViewerScene : public QGraphicsScene
- {
- Q_OBJECT
- public:
- ViewerScene(QWidget* parent = 0, const char* name = 0);
- void setBackgroundPixmap(const QPixmap& pixmap);
- void setRect(const QRect& rect);
- void getRect(QRect& rect);
- protected:
- virtual void drawBackground(QPainter* painter, const QRectF& rect);
- private:
- QPixmap m_backgroundPixmap;
- QRect m_rect;
- void ViewerScene::drawBackground(QPainter* painter, const QRectF & rect)
- {
- QRect sourceRect(0, 0, m_backgroundPixmap.width(),
- m_backgroundPixmap.height());
- painter->drawPixmap(m_rect, m_backgroundPixmap, sourceRect);
- QGraphicsScene::drawBackground(painter, rect);
- }
- QRect r;
- scene->getRect(r);
- QPoint p = your_QGraphicsView->mapFromScene(r.topLeft());
- qDebug() << p;
Add Comment
Please, Sign In to add comment