Paste

URL To paste - | raw - Sun Jan 27 2019 17:38:50 GMT+0000 (Coordinated Universal Time)
#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);
  }
}