2016-09-16 29 views
1

我試圖讓右軸可拖動。QCustomPlot和iRangeDrag在第二個右邊yAxis

現在使用其中一個站點示例,通過雙擊它可以使第一個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相關,而不是它們兩個。

+0

任何人有想法? – user217354

回答

0

我通過修改代碼來解決,以便在右軸上執行拖動調用。 如果我們看一下左軸上會發生什麼,這是非常簡單的。

相關問題