Qt gui expand and compress Y axis

25 Views Asked by At

I’m trying to implement a feature in a QChart where dragging the mouse up and down on the Y-axis labels resizes the Y-axis range, giving the illusion of elongating or compressing the candlesticks in a QCandlestickSeries. However, when I attempt to do this, the entire chart continues to move instead of adjusting the Y-axis.

Here’s what I have tried:

1.  Detecting Y-axis Clicks:

I implemented a custom mouse press event in a CustomChartView class (derived from QChartView) to check if a user clicks within the Y-axis region:

void CustomChartView::mousePressEvent(QMouseEvent* event) {
    if (event->button() == Qt::LeftButton && event->pos().x() <= 50) {
        m_axisResizing = true;
    } else {
        m_isDragging = true;
        QChartView::mousePressEvent(event);
    }
}

2.  Disabling ScrollBars:

Temporarily commented out the connections to the QScrollBar valueChanged signals to eliminate potential conflicts, but the issue persisted.

Despite the above, every time I attempt to resize the Y-axis by dragging, the entire chart moves.

Has anyone faced a similar issue, or can suggest how to prevent the chart from moving and only resize the Y-axis?

0

There are 0 best solutions below