QCustomPlot Discussion and Comments

QBrush with QLinearGradientReturn to overview

I have a plot with multiple charts in it. I want to fill out the aeras underneath the graph with QBrush with a QLinearGradient. I was already able to do this when I have only one chart in the plot, but for some reason I don't get it to run properly with multiple charts:

Here a part of the code until to the definition of QBrush for the first chart

Plot->plotLayout()->clear();
    QCPAxisRect *TempPlot = new QCPAxisRect(Plot);
    QCPAxisRect *HydPlot = new QCPAxisRect(Plot);
    QCPAxisRect *DruckPlot = new QCPAxisRect(Plot);
    Plot->plotLayout()->addElement(0, 0, TempPlot);
    Plot->plotLayout()->addElement(1, 0, HydPlot);
    Plot->plotLayout()->addElement(2, 0, DruckPlot)

    //Temp-chart
    QCPGraph *TempGraph = Plot->addGraph(TempPlot->axis(QCPAxis::atBottom), TempPlot->axis(QCPAxis::atLeft));
    TempGraph->setData(xZeitpunkt, LuftTemp);
    TempGraph->rescaleAxes();
    //X-axis to time axis
    QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime);
    dateTicker->setDateTimeFormat("d. MMMM\nyyyy");
    dateTicker->setTickCount(7);
    TempPlot->axis(QCPAxis::atBottom)->setTicker(dateTicker);
    TempPlot->axis(QCPAxis::atBottom)->setRange(xZeitpunkt[0], xZeitpunkt[zulesendeZeilen-2]);
    
    //definition of gradient for brushing graph
    QLinearGradient tempgradient(TempPlot->bottomLeft(), TempPlot->topLeft());
    tempgradient.setColorAt(0, QColor(0, 0, 255, 200));
    tempgradient.setColorAt(1, QColor(255, 100, 0, 200));
    TempGraph->setBrush(QBrush(tempgradient));

When I run the program, the area underneath the graph is filled with the color defined at " tempgradient.setColorAt(1, QColor(255, 100, 0, 200));" but no gradient is visible. When I define the gradient manually without the "TempPlot->bottomLeft(), TempPlot->topLeft()" and type in some random coordinates, I can see the gradient.
The goal should be to have a gradient from the bottom of the chart up to the top, but I guess I haven't defined the tempgradient correct.


or asked in a simpler way:
How can I get the position in pixel of the left corner at the bottom or at the top of a QCPAxisRect?
In my code "TempPlot" is a QCPAxisRect, but for some reason "TempPlot->bottomLeft()" and "TempPlot->topLeft()" don't work