You may use a custom delegate with different padding values.
You may use a custom delegate with different padding values.
I'm not sure exactly what you mean. I looked in QItemDelegate source, and I see that there is a hardcoded text margin of 3. Is this what you mean? It is the only thing I can find that could be considered "padding". Will I have to rewrite all of QItemDelegate's display code in order to resize some rows? In such a case I might as well inherit from QAbstractItemDelegate instead!
I am aghast that something that should be simple is so difficult. Am I just being stupid?
Solved! It turns out that even though the vertical header is hidden, it is still being used to calculate the minimum row height. The only way I can figure to change this is by tweaking the font size for the header. Since it's hidden the smaller font won't be seen. That's probably not the best solution, but it works.
Last edited by Brandybuck; 7th April 2006 at 08:10. Reason: solution found
Item size is determined by the size returned by delegate's sizeHint method, which is in turn based on getting data from SizeHintRole of the item, so you can either reimplement sizeHint(), set data for SizeHintRole of the items (or the whole model) or reimplement the delegate's painting routine (note that this will not alter the cell size, only its content).Originally Posted by Brandybuck
I eventually discovered that, but it wasn't working for me. My problem was that the QHeaderView was placing a minimum size on the row heights, so that while I could make the rows bigger, I could not make them smaller. See my solution above.Originally Posted by wysota
I still have a problem with my row heights. I cannot make the font of my headers smaller, because I use them. And the size hint I set in my costum item delegate only works for the actual table cells, but not for the headers.
Does anyone know how I can set the row heights for the headers?
Bye,
Andreas
Bookmarks