Greadimar
Greadimar

Reputation: 101

QTableView columns - can't set small width

I have two QTableView with own simple models. After making the following:

    tv1->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    tv1->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    tv1->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
    tv1->resizeColumnsToContents();

I have this picture:

enter image description here

And here what I want:

enter image description here

What I've tried:

Nothing of these works. I am desperate enough to draw the table from zero with QPainter or follow every source file to watch the real size. But before that, I would appreciate for any advice.

Upvotes: 3

Views: 1946

Answers (1)

p-a-o-l-o
p-a-o-l-o

Reputation: 10077

You can try setting the minimum section size to zero for the horizontal header, this way:

tv1->horizontalHeader()->setMinimumSectionSize(0);

(Docs here).

Upvotes: 2

Related Questions