QCustomPlot Discussion and Comments

Bug in QCPAxis with QCPAxis::setTicks and QCPAxis::setTickLabelsReturn to overview

In document, the description of QCPAxis::setTicks and QCPAxis::setTickLabels are:
void QCPAxis::setTicks ( bool show)
Sets whether tick marks are displayed.

Note that setting show to false does not imply that tick labels are invisible, too. To achieve that, see setTickLabels.

void QCPAxis::setTickLabels ( bool show)
Sets whether tick labels are displayed. Tick labels are the numbers drawn next to tick marks.

That means, whatever setTicks(false), but setTickLabels(true), the text of tick labels will be shown. But in fact, when setTicks(false), whatever setTickLabels(true) or setTickLabels(false), the text of tick labels will not be shown.

In the source code of qcustomplot.cpp, threre are
void QCPAxis::setTicks(bool show)
{
if (mTicks != show)
{
mTicks = show;
mCachedMarginValid = false;
}
}
void QCPAxis::setTickLabels(bool show)
{
if (mTickLabels != show)
{
mTickLabels = show;
mCachedMarginValid = false;
if (!mTickLabels)
mTickVectorLabels.clear();
}
}
void QCPAxis::draw(QCPPainter *painter)
{
QVector<double> subTickPositions; // the final coordToPixel transformed vector passed to QCPAxisPainter
QVector<double> tickPositions; // the final coordToPixel transformed vector passed to QCPAxisPainter
QVector<QString> tickLabels; // the final vector passed to QCPAxisPainter
tickPositions.reserve(mTickVector.size());
tickLabels.reserve(mTickVector.size());
subTickPositions.reserve(mSubTickVector.size());

if (mTicks)
{
for (int i=0; i<mTickVector.size(); ++i)
{
tickPositions.append(coordToPixel(mTickVector.at(i)));
if (mTickLabels)
tickLabels.append(mTickVectorLabels.at(i));
}

if (mSubTicks)
{
const int subTickCount = mSubTickVector.size();
for (int i=0; i<subTickCount; ++i)
subTickPositions.append(coordToPixel(mSubTickVector.at(i)));
}
}
......
}

when mTicks is false(because setTicks(false)), tickLabels has nothing to show. The action does not match the description in the help document. So I think this is a bug.

Thank God, I have also encountered the same issue as you, and the description in the documentation does not match the actual situation. After carefully studying the source code, I found that mTicks controls mTickLabels. I hope the author can update the documentation or the source code.
Best wishes!