Hi!

How to make the outer legend such small as possible?
Also, I want to remove the black frame around the legend.
Also, I need to make the legend font smaller. If I try to make the legend font little bit smaller, the legend line still has the same height, but the legend text begins to cuddle up to the upper border.

My code:

    m_customPlot->legend->setVisible(true);

    QCPLayoutGrid *subLayout = new QCPLayoutGrid;
    m_customPlot->plotLayout()->addElement(1, 0, subLayout);
    // subLayout->setMargins(QMargins(5, 0, 5, 5));
    subLayout->setMargins(QMargins(70, 0, 70, 2)); // make it centered
    subLayout->addElement(0, 0, m_customPlot->legend);
    // change the fill order of the legend, so it's filled left to right in columns:
    m_customPlot->legend->setFillOrder(QCPLegend::foColumnsFirst);
    // set legend's row stretch factor very small so it ends up with minimum height:
    m_customPlot->plotLayout()->setRowStretchFactor(1, 0.001);

    m_customPlot->plotLayout()->setColumnStretchFactor(1, 0.001);

    m_customPlot->legend->setRowSpacing(0);

    auto legendFont = m_customPlot->legend->font();
    auto legendFontPointSize = legendFont.pointSize();
    legendFontPointSize -= 2;
    if (legendFontPointSize>0)
    {
        legendFont.setPointSize(legendFontPointSize);
        m_customPlot->legend->setFont(legendFont);
    }