TreeView Model: Resize header column
-
wrote on 25 Sept 2014, 09:12 last edited by
Hey Guys,
I have got a treeview (+model) with a two column header. Now the width from the first row have to be larger than the second. But I don't know how to implement it.
I just can resize the height of both rows.
In headerData Methode:
@ if(role == Qt::SizeHintRole)
{
return QSize(30, 30);
}@ -
Hi,
Try "resizeSection":http://qt-project.org/doc/qt-5/qheaderview.html#resizeSection. You could access it using header() of QTreeView.
-
wrote on 25 Sept 2014, 10:33 last edited by
A two row header? It would mean the header is vertical but treeviews don't have those. In any case rows have always the same width but can differ in height. Did you maybe mean a column?
In headerData() you get the first parameter that indicates which header section it is. You can differentiate on that eg.
@
switch(section) {
default: return /something/;
case 0: return /something else/;
case 1: return /something else entirely/;
}
@ -
wrote on 25 Sept 2014, 11:15 last edited by
Ohhh, yes of course i mean coloumn instead of row, sry -.-'. I edited it in main post.
[at ]p3c0
But I can't access the view from my model or how can I call resizeSection?[at] chrisaverage
I tried this:
@ if(role == Qt::SizeHintRole)
{
switch(section) {
case 0: return QSize(70, 30);
case 1: return QSize(30, 30);
}
}@But it doesn't work. When I change both height values from 30 to for example 20, the height goes smaller. So I think return a QSize works, but only for height not for witdh. :(
-
wrote on 26 Sept 2014, 07:16 last edited by
Mhm has nobody an idea? :(
3/5