mirror of https://github.com/qt/qtgraphs.git
Update GraphView when series axis is changed
Fixes: QTBUG-138598 Pick-to: 6.10 Change-Id: I456dfa64244acfedbd11a68e5de9fbe31c2174e2 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
This commit is contained in:
parent
6ba5d8f00c
commit
453df72f28
|
|
@ -484,13 +484,20 @@ void QAbstractSeries::setAxisX(QAbstractAxis *newAxisX)
|
|||
if (d->m_axisX == newAxisX)
|
||||
return;
|
||||
|
||||
if (d->m_axisX)
|
||||
if (d->m_axisX) {
|
||||
disconnect(d->m_axisX, &QAbstractAxis::update, this, &QAbstractSeries::update);
|
||||
|
||||
if (d->m_graph)
|
||||
d->m_graph->removeAxis(d->m_axisX);
|
||||
}
|
||||
|
||||
if (newAxisX) {
|
||||
if (newAxisX->alignment() != Qt::AlignBottom && newAxisX->alignment() != Qt::AlignTop)
|
||||
newAxisX->setAlignment(Qt::AlignBottom);
|
||||
connect(newAxisX, &QAbstractAxis::update, this, &QAbstractSeries::update);
|
||||
|
||||
if (d->m_graph)
|
||||
d->m_graph->addAxis(newAxisX);
|
||||
}
|
||||
|
||||
d->m_axisX = newAxisX;
|
||||
|
|
@ -510,13 +517,20 @@ void QAbstractSeries::setAxisY(QAbstractAxis *newAxisY)
|
|||
if (d->m_axisY == newAxisY)
|
||||
return;
|
||||
|
||||
if (d->m_axisY)
|
||||
if (d->m_axisY) {
|
||||
disconnect(d->m_axisY, &QAbstractAxis::update, this, &QAbstractSeries::update);
|
||||
|
||||
if (d->m_graph)
|
||||
d->m_graph->removeAxis(d->m_axisY);
|
||||
}
|
||||
|
||||
if (newAxisY) {
|
||||
if (newAxisY->alignment() != Qt::AlignLeft && newAxisY->alignment() != Qt::AlignRight)
|
||||
newAxisY->setAlignment(Qt::AlignLeft);
|
||||
connect(newAxisY, &QAbstractAxis::update, this, &QAbstractSeries::update);
|
||||
|
||||
if (d->m_graph)
|
||||
d->m_graph->addAxis(newAxisY);
|
||||
}
|
||||
|
||||
d->m_axisY = newAxisY;
|
||||
|
|
|
|||
|
|
@ -249,10 +249,22 @@ void QGraphsView::addAxis(QAbstractAxis *axis)
|
|||
|
||||
void QGraphsView::removeAxis(QAbstractAxis *axis)
|
||||
{
|
||||
if (m_axisX == axis || m_axisY == axis) {
|
||||
axis->d_func()->setGraph(nullptr);
|
||||
QObject::disconnect(axis, &QAbstractAxis::update, this, &QGraphsView::polishAndUpdate);
|
||||
QObject::disconnect(axis,
|
||||
&QAbstractAxis::visibleChanged,
|
||||
this,
|
||||
&QGraphsView::updateComponentSizes);
|
||||
}
|
||||
|
||||
if (m_axisX == axis)
|
||||
m_axisX = nullptr;
|
||||
if (m_axisY == axis)
|
||||
m_axisY = nullptr;
|
||||
|
||||
updateComponentSizes();
|
||||
polishAndUpdate();
|
||||
}
|
||||
|
||||
qsizetype QGraphsView::graphSeriesCount() const
|
||||
|
|
@ -1366,7 +1378,8 @@ void QGraphsView::setAxisX(QAbstractAxis *axis)
|
|||
<< "value is already set to:" << axis;
|
||||
return;
|
||||
}
|
||||
removeAxis(m_axisX);
|
||||
if (m_axisX)
|
||||
removeAxis(m_axisX);
|
||||
m_axisX = axis;
|
||||
if (axis) {
|
||||
if (axis->alignment() != Qt::AlignBottom && axis->alignment() != Qt::AlignTop)
|
||||
|
|
@ -1403,7 +1416,8 @@ void QGraphsView::setAxisY(QAbstractAxis *axis)
|
|||
<< "value is already set to:" << axis;
|
||||
return;
|
||||
}
|
||||
removeAxis(m_axisY);
|
||||
if (m_axisY)
|
||||
removeAxis(m_axisY);
|
||||
m_axisY = axis;
|
||||
if (axis) {
|
||||
if (axis->alignment() != Qt::AlignLeft && axis->alignment() != Qt::AlignRight)
|
||||
|
|
|
|||
Loading…
Reference in New Issue