PDA

View Full Version : Cannot select QHeaderView in area reserved for resize even if resize is not enabled



dpace
7th May 2011, 00:28
Hi,

I have a QTableView that uses both vertical and horizontal headers. The resize mode of the vertical headers (for the rows) is set to QHeaderView::Fixed so that the user cannot resize the rows. The height of the rows is pretty small (19px).

The trouble is that when I try to click in the upper part of the header (top 4px), selection of the header does not happen. This appears to be because there are a number of pixels reserved for the gripper for resizing the column header. See QHeaderViewPrivate::sectionHandleAt() (4.7.2).

4 pixels may not seem like much, but when the total height is 19, this "dead spot" for selection is quite noticeable.

I'm fairly new to Qt and quite new to styles but I was hoping that I could override the pixel metrics for PM_HeaderGripMargin using a stylesheet rather than in code but this doesn't seem possible.

Anyone have any suggestions on how to make the dead zone selectable?

Thanks,
Dave

dpace
9th May 2011, 21:45
I was able to workaround this issue by subclassing QProxyStyle and overriding pixelMetrics() to return zero.