I’m working on a pixel art drawing software.
When drawing in other software I can make lines such as those using a fast mouse movement:
When in my software the lines look like following:
Correct me if I’m wrong but I feel like the issue is in low pooling rate of Qt’s mouseMoveEvent function that I overwrite inside my widget that inherits QGraphicsView, here is my implementation:
const auto movingThroughPixel = mapPositionOfEventToScene(event); // this uses mapToScene(event->position().toPoint()); and checks if pixel is in the drawing
if (movingThroughPixel.has_value()) {
const auto clickedPixelX = movingThroughPixel->x();
const auto clickedPixelY = movingThroughPixel->y();
_drawing.drawPixelOnCurrentLayer(clickedPixelX,
clickedPixelY,
QColor(0, 255, 0, 255));
const auto combinedColor = _drawing.calculateCombinedPixelColor(
clickedPixelX, clickedPixelY);
_drawing_canvas_item->updateCanvasPixel(clickedPixelX, clickedPixelY,
combinedColor); // this calls QImage's setPixelColor and update() inside widget inheriting QGraphicsItem
}
Is there any way to increase the pooling rate if that’s the issue? And if not am I using completely wrong tool for the job? I have no knowledge of OpenGL or any other graphics library so I was hoping to implement this program fully in Qt.