c++ - QCustomPlot 和 iRangeDrag 在第二个右边的 yAxis

标签 c++ qt qcustomplot

我正在尝试使右轴可拖动。

现在使用其中一个站点示例,我可以通过双击使第一个 yAxis 可拖动。

void MainWindow::mousePress()
{
// if an axis is selected, only allow the direction of that axis to be dragged
// if no axis is selected, both directions may be dragged

if (ui->customPlot->xAxis->selectedParts().testFlag(QCPAxis::spAxis))
    ui->customPlot->axisRect()->setRangeDrag(ui->customPlot->xAxis->orientation());
else if (ui->customPlot->yAxis->selectedParts().testFlag(QCPAxis::spAxis))
    ui->customPlot->axisRect()->setRangeDrag(ui->customPlot->yAxis->orientation());
else if (ui->customPlot->yAxis2->selectedParts().testFlag(QCPAxis::spAxis))
    ui->customPlot->axisRect()->setRangeDrag(ui->customPlot->yAxis2->orientation());
else
    ui->customPlot->axisRect()->setRangeDrag(Qt::Horizontal|Qt::Vertical);
}

我的图表有 2 条线,每条线都有不同的 yAxis。 我想要实现的是在第二个(右侧)yAxis 上实现相同的可拖动效果,它称为 yAxis2。 使用下面的代码,即使我选择了 yAxis2,也是垂直拖动的 yAxis

我猜问题出在 axisRect() 中,它只与左侧 yAxis 相关,而不是两者都相关。

最佳答案

我通过修改代码来解决问题,以便在右轴上也执行拖动调用。 如果看一下左轴上发生的情况,就会非常简单。

关于c++ - QCustomPlot 和 iRangeDrag 在第二个右边的 yAxis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39530718/

相关文章:

c++ - QCustomPlot include 在 Linux/Ubuntu 上导致奇怪的错误

java - 密码破解

C++ 成员引用基类型 'Vertex *const' 不是结构或 union

c++ - Q_INVOKABLE const getter 返回 undefined,non-const getter 返回正确值 - 为什么?

c++ - Qt 多语言应用程序

c++ - Qt 子类 QStyledItemDelegate 不提供对列的编辑

c++ - 如何将轴移动到 QCustomPlot 的中间

C++ stoi 无法解析使用 eclipse 编译

c++ - 实现编译时机制检查字符串的唯一性