문제

Is there any way of showing ticks and subticks over zerolines in QCustomPlot? I couldn't find anything in documentation.

도움이 되었습니까?

해결책 2

I had to create ticks and subticks with QCPItemLine. Here is the code:

for(int i=-65; i<=65; i+=10)
{
    // Ticks
    QCPItemLine *tickHLine=new QCPItemLine(ui->customPlot);
    ui->customPlot->addItem(tickHLine);
    tickHLine->start->setCoords(i,-1);
    tickHLine->end->setCoords(i,1);
    tickHLine->setPen(QPen(QColor(137, 140, 140), 1));

    //Subticks
    QCPItemLine *subTickHLine=new QCPItemLine(ui->customPlot);
    ui->customPlot->addItem(subTickHLine);
    subTickHLine->start->setCoords(i+5,-2);
    subTickHLine->end->setCoords(i+5,2);
    subTickHLine->setPen(QPen(QColor(137, 140, 140), 1));
}

다른 팁

You may have your layers mixed up. Make sure your grid is on a layer below the axis, because the zero line is part of the grid, and the ticks part of the axis. So for example:

axis->setLayer("axes");
axis->grid()->setLayer("grid");

Note that "axes" and "grid" are layers that exist by default. And normally the grid is already placed on the correct layer, so what you are experiencing is probably due to clearing the default setup/plot layout and then creating a new axis rect all on one layer.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top