QCustomPlot Discussion and Comments

Updating plot titleReturn to overview

QCustomPlot 2.0.0-beta

I want users to be able to add, remove or modify plot titles. I made the following function. It does not remove titles but keeps adding more of them.

/*! \brief Set the plot title.
 * \note Pass a null string (QString()) to only remove the existing title.
 * \note If a previous title exists, it will be removed.
 * \param title - Desired title (or null)
 */
void MyaPlot::SetTitle(const QString &title)
{
  // Remove any existing title.
  if (!m_title.isNull())
  { m_title= QString();
    plotLayout()->removeAt(plotLayout()->rowColToIndex(0, 0));
    plotLayout()->simplify();
  }
  
  // Add a title if a non-null string was passed.
  if (!title.isNull())
  { plotLayout()->insertRow(0);
    plotLayout()->addElement(0, 0, new QCPTextElement(this, title));
  }
}

Simple fix to add m_title = title after line #18 above. Sorry for the post.