URL To paste - | raw -
Sun Jan 27 2019 16:04:13 GMT+0000 (Coordinated Universal Time)
#include <QApplication>
#include <QStandardItemModel>
#include <QTableView>
#include <memory>
#include "mheaderview.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QStandardItemModel model(4, 4);
for (int row = 0; row < 4; ++row)
{
for (int column = 0; column < 4; ++column)
{
QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
model.setItem(row, column, item);
}
}
auto view = std::make_unique<QTableView>();
MHeaderView *header = new MHeaderView(Qt::Horizontal, view.get());
view->setModel(&model);
view->setHorizontalHeader(header);
view->resize(800, 600);
header->setIdealColumnSize(0);
header->setSectionResizeMode(1, QHeaderView::Fixed);
header->setSectionResizeMode(2, QHeaderView::Fixed);
header->setSectionResizeMode(3, QHeaderView::Fixed);
header->setCascadingSectionResizes(true);
view->show();
return a.exec();
}