Значок раскрытия / свертывания, наряду со всеми другими линиями ветвления дерева, действительно вынужден всегда рисовать в нулевом логическом столбце.В Qt / 4.8.4 / src / gui / itemviews / qtreeview.cpp в методе QTreeView::drawRow()
он жестко задан для вызова QTreeView::drawBranches()
, только если headerSection
(который содержит логический индекс столбца) равен нулю.
void QTreeView::drawRow( QPainter * painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
...
for ( int currentLogicalSection = 0; currentLogicalSection < logicalIndices.count(); ++currentLogicalSection )
{
int headerSection = logicalIndices.at(currentLogicalSection);
...
// If the zeroeth logical column, ...
if ( headerSection == 0 )
{
...
// ... draw tree branches and stuff.
drawBranches(painter, branches, index);
}
else
{
...
}
...
}
...
}