#include "mheaderview.h" MHeaderView::MHeaderView(Qt::Orientation orientation, QWidget *parent) : QHeaderView(orientation, parent) { } void MHeaderView::stretchColumn(int logicalIndex) { QAbstractItemModel *mod = model(); if (mod == nullptr) { return; } int oldSize = sectionSize(logicalIndex); int availableWidth = width(); for (int i = 0; i < length(); i++) { if (sectionResizeMode(i) == QHeaderView::Fixed) { availableWidth -= sectionSize(i); } else { availableWidth -= sectionSizeHint(i); } } if (availableWidth != oldSize) { resizeSection(logicalIndex, availableWidth); emit sectionResized(logicalIndex, oldSize, availableWidth); } }