Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "GraphicsScene.hpp"
- #include <QtCore>
- #include <QtGui>
- QDMGraphicsScene::QDMGraphicsScene(QWidget* pobj)
- : QGraphicsScene(pobj)
- {
- setSceneRect(-(scnWidth / 2), -(scnHeight / 2), scnWidth, scnHeight);
- setBackgroundBrush(QColor("#393939"));
- }
- // Virtual:
- void QDMGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect)
- {
- // Problem was here:
- // Adding this and it'll work:
- QGraphicsScene::drawBackground(painter, rect);
- QPen ppLight(QColor("#2f2f2f"));
- ppLight.setWidth(1);
- int32_t left = static_cast<int32_t>(rect.left());
- int32_t right = static_cast<int32_t>(rect.right());
- int32_t top = static_cast<int32_t>(rect.top());
- int32_t bottom = static_cast<int32_t>(rect.bottom());
- int32_t first_left = left - (left % grdSize);
- QVector<QLine> gridVector;
- for (int32_t x = first_left; x < right; x += grdSize)
- {
- gridVector.push_back(QLine(x, top, x, bottom));
- }
- painter->setPen(ppLight);
- painter->drawLines(gridVector);
- }
Add Comment
Please, Sign In to add comment