46 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
47 setSectionsClickable(
true);
48 setSectionResizeMode(Fixed);
53 setDefaultSectionSize(27);
58 if (orientation() == Qt::Vertical)
60 QHeaderView::paintSection(painter, rect, logicalIndex);
66 painter->translate(rect.x(), rect.y());
68 painter->translate(-rect.height(), 0);
69 QHeaderView::paintSection(painter, QRect(0, 0, rect.height(), rect.width()), logicalIndex);
75 if (orientation() == Qt::Vertical)
76 return QHeaderView::sectionSizeFromContents(logicalIndex);
78 Q_ASSERT(logicalIndex >= 0);
83 QVariant variant = model()->headerData(logicalIndex, Qt::Vertical, Qt::SizeHintRole);
84 if (variant.isValid())
85 return qvariant_cast<QSize>(variant);
88 QStyleOptionHeader
opt;
89 initStyleOption(&
opt);
90 opt.section = logicalIndex;
91 QVariant var = model()->headerData(logicalIndex, orientation(), Qt::FontRole);
93 if (var.isValid() && var.canConvert<QFont>())
94 fnt = qvariant_cast<QFont>(var);
98 opt.fontMetrics = QFontMetrics(fnt);
99 opt.text = model()->headerData(logicalIndex, orientation(), Qt::DisplayRole).toString();
100 variant = model()->headerData(logicalIndex, orientation(), Qt::DecorationRole);
101 opt.icon = qvariant_cast<QIcon>(variant);
102 if (
opt.icon.isNull())
103 opt.icon = qvariant_cast<QPixmap>(variant);
104 QSize size = style()->sizeFromContents(QStyle::CT_HeaderSection, &
opt, QSize(),
this);
105 if (isSortIndicatorShown())
107 int margin = style()->pixelMetric(QStyle::PM_HeaderMargin, &
opt,
this);
108 if (orientation() == Qt::Horizontal)
109 size.rwidth() += size.height() + margin;
111 size.rheight() += size.width() + margin;
113 return QSize(size.height(), size.width());
118 if (isSectionHidden(logicalIndex))
120 if (logicalIndex < 0 || logicalIndex >= count())
123 QVariant value = model()->headerData(logicalIndex, orientation(), Qt::SizeHintRole);
125 size = qvariant_cast<QSize>(value);
128 int hint = size.height();
129 return qMax(minimumSectionSize(), hint);