So I find a solution which works perfectly, I finally set a zoom like the google maps zoom.

The solution is :

catch the widget wheel event in the plot magnifier

create a private method in the plot magnifier rescale_on_cursor(double factor, int x_cursor, int y_cursor, QSize parent_size)

In the widget wheel event you will call your method. The factor will be 0,9 or 1,1 (unzoom or zoom), (x, y) the cursor position and QSize the size of the parent widget.

The main idea is to derivate the qwt_plotMagnifier::rescale() and to modify the step where you define the new scale, you will set a percentage of the scale which is equals to the percent of the cursor position.

If x_cursor is equals to 20% of the parent size you will setAxisScale(20%(zoom), 80%(zoom)).

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐