<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to zoom in or out of a Chart using QCustomPlot but using push buttons rather than a mouseWheel]]></title><description><![CDATA[<p dir="auto">The QCustomPlot library offers users the ability to zoom in and out of the graph drawn on the custom chart when they enable the Zoom interaction. Now What I want is for to zoom in an out of the graph in the same manner but with two Push Buttons. One for zooming in and another for zooming out.</p>
<p dir="auto">How would I go on about something like that? I just want the user to be able to zoom in into the widget that contains the graphs or zoom out when one of those buttons are clicked.</p>
<p dir="auto">Is there a way in the library that allows me to manually trigger the zooming effect or do I perhaps scale the widget itself to emulate the zooming effect?</p>
]]></description><link>https://forum.qt.io/topic/139560/how-to-zoom-in-or-out-of-a-chart-using-qcustomplot-but-using-push-buttons-rather-than-a-mousewheel</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 02:50:53 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139560.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 25 Sep 2022 15:50:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to zoom in or out of a Chart using QCustomPlot but using push buttons rather than a mouseWheel on Tue, 27 Sep 2022 09:37:29 GMT]]></title><description><![CDATA[<p dir="auto">Does this help? (it is code from a custom QWidget)</p>
<pre><code>    void ImageView::keyPressEvent(QKeyEvent* e)
    {
        const QPointF mouseLocation(mapFromGlobal(QCursor::pos()));
        bool handled = false;
        switch (e-&gt;key())
        {
        case Qt::Key_Plus:
        case Qt::Key_Equal:
            // Handle Ctrl+= and Ctrl++ as Zoom in 
            if (e-&gt;modifiers() &amp; Qt::ControlModifier)
            {
                zoom(mouseLocation, 1);
                handled = true;
            }
            break;
        case Qt::Key_Minus:
            // Handle Ctrl+- as Zoom out
            if (e-&gt;modifiers() &amp; Qt::ControlModifier)
            {
                zoom(mouseLocation, -1);
                handled = true;
            }
            break;
        default:
            break;
        }

        if (!handled)
            QWidget::keyPressEvent(e);
    }
</code></pre>
]]></description><link>https://forum.qt.io/post/730310</link><guid isPermaLink="true">https://forum.qt.io/post/730310</guid><dc:creator><![CDATA[Perdrix]]></dc:creator><pubDate>Tue, 27 Sep 2022 09:37:29 GMT</pubDate></item></channel></rss>