29 #include <QTreeWidget>
31 #include <QHeaderView>
32 using namespace Utils;
35 : QObject(treeWidget->header()), m_columnToStretch(columnToStretch)
37 parent()->installEventFilter(
this);
44 if (obj == parent()) {
45 if (ev->type() == QEvent::Show) {
46 QHeaderView *hv = qobject_cast<QHeaderView*>(obj);
47 for (
int i = 0;
i < hv->count(); ++
i)
48 hv->setSectionResizeMode(
i, QHeaderView::Interactive);
49 }
else if (ev->type() == QEvent::Hide) {
50 QHeaderView *hv = qobject_cast<QHeaderView*>(obj);
51 for (
int i = 0;
i < hv->count(); ++
i)
52 hv->setSectionResizeMode(
i,
i == m_columnToStretch ? QHeaderView::Stretch : QHeaderView::ResizeToContents);
53 }
else if (ev->type() == QEvent::Resize) {
54 QHeaderView *hv = qobject_cast<QHeaderView*>(obj);
55 if (hv->sectionResizeMode(m_columnToStretch) == QHeaderView::Interactive) {
56 QResizeEvent *re =
static_cast<QResizeEvent*
>(ev);
57 int diff = re->size().width() - re->oldSize().width() ;
58 hv->resizeSection(m_columnToStretch, qMax(32, hv->sectionSize(1) +
diff));