PDA

View Full Version : Changing only the parent and font-size of QstyledItemDelegate's Editor



davethomaspilot
8th February 2014, 22:37
I've implemented a class derived from a QStyledItemDelegate so that I can present a custom widget for editing some columns of QSqlTableModel / QTableView. That's working.

The default editors for most columns are QSpinBoxs. That's fine, except I want them bigger. So, the editor's parent needs to be 0 and the font size needs to be much larger than the default (which sizes nicely to fit in the TableView row, but is too small for touch applications).

I did this for the columns with custom widgets and could do the same for these other columns. But, is there a way to change only the parent of the default editor and the font point size so I don't have to have totally custom widgets for these too?

I tried using the QStyleOptionViewItem passed in the virtual QStyledItemDelegate::createEditor method for setting the font size. But it's a const &, so I can't change it in my implementation.

Thanks,

Dave Thomas

anda_skoa
9th February 2014, 14:52
I tried using the QStyleOptionViewItem passed in the virtual QStyledItemDelegate::createEditor method for setting the font size. But it's a const &, so I can't change it in my implementation.

You can create a local copy and modify that.



QStyleOptionViewItem myOption = option;
// modify myOption


Cheers,
_