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>())
95 fnt = qvariant_cast<QFont>(var);
102 opt.fontMetrics = QFontMetrics(fnt);
103 opt.text = model()->headerData(logicalIndex, orientation(), Qt::DisplayRole).toString();
104 variant = model()->headerData(logicalIndex, orientation(), Qt::DecorationRole);
105 opt.icon = qvariant_cast<QIcon>(variant);
106 if (opt.icon.isNull())
107 opt.icon = qvariant_cast<QPixmap>(variant);
108 QSize size = style()->sizeFromContents(QStyle::CT_HeaderSection, &opt, QSize(),
this);
109 if (isSortIndicatorShown())
111 int margin = style()->pixelMetric(QStyle::PM_HeaderMargin, &opt,
this);
112 if (orientation() == Qt::Horizontal)
114 size.rwidth() += size.height() + margin;
118 size.rheight() += size.width() + margin;
121 return QSize(size.height(), size.width());
126 if (isSectionHidden(logicalIndex))
128 if (logicalIndex < 0 || logicalIndex >= count())
131 QVariant value = model()->headerData(logicalIndex, orientation(), Qt::SizeHintRole);
134 size = qvariant_cast<QSize>(value);
140 int hint = size.height();
141 return qMax(minimumSectionSize(), hint);