April 2018
Beginner
714 pages
18h 21m
English
Our graph currently contains points with integer x values because we set DX = 1. This is exactly what we want for the default level of zoom, but once the view is zoomed in, it becomes apparent that the graph's line is not smooth. We need to change DX based on the current zoom level. We can do this by adding the following code to the beginning of the paint() function():
const qreal detail = QStyleOptionGraphicsItem::levelOfDetailFromTransform(
painter->worldTransform());
const qreal dx = 1 / detail;
Delete the DX constant and replace DX with dx in the rest of the code. Now, when you scale the view, the graph's line keeps being smooth because the number of points increases dynamically. The ...
Read now
Unlock full access