PDA

View Full Version : QTableView with Styled Item Delegate as QToolButton



LynneV
29th October 2014, 14:54
Hello, I have a QTableView with a model column that has the Qt::DecorationRole set with a small image. The cell is editable, and I want to use a QToolButton as the ItemDelegate editor widget.

My problem is that the ItemDelegate Style option rectangle is always too wide and the button is always drawn right justified in the space. It draws the QToolButton to the right of the Qt::DecorationRole image in the table cell, and if the column is narrow enough to just fit the image width, the button is hidden under the column to the right. The column needs to be resized to show the button (see attached images). Does anyone know why? I think it should use the cell area for drawing, and superimpose the editor in the space by default. I have tried setting the SizeHintRole, setting the size directly and changing the column width. I know I can paint it any way I want. But I'd like to understand why the hierarchy of setting the default editor size chooses the size it does! Thanks in advance for any help - much appreciated.