I try to modify the text of my QHeaderView (Horizontal) in my QTableWidget.
First question: Is it possible to set it editable like a QTableWidgetItem ?
Second question: If it's not possible, how can I do that, I tried to repaint it like this:
void EditableHeaderView::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const
{
painter->save();
QHeaderView::paintSection(painter, rect, logicalIndex);
painter->restore();
painter->setPen(Qt::SolidLine);
painter->drawText(rect, Qt::AlignCenter, m_sValues[logicalIndex]);
}
But the header index is painted behind my text.
Another solution that I tried is:
void EditableHeaderView::mySectionDoubleClicked( int section )
{
if (section != -1) // Not on a section
m_sValues[section] = QInputDialog::getText(this, tr("Enter a value"), tr("Enter a value"), QLineEdit::Normal, "");
QAbstractItemModel* model = this->model();
model->setHeaderData(section, this->orientation(), m_sValues[section]);
this->setModel(model);
}
But that doesn't works...
I hope someone have a solution.
Thank you !