[Interest] Change QCheckBox to QPushButton in a QTableView
Jason H
jhihn at gmx.com
Thu Dec 7 15:20:53 CET 2017
> Sent: Thursday, December 07, 2017 at 1:10 AM
> From: "André Somers" <andre at familiesomers.nl>
> To: interest at qt-project.org
> Subject: Re: [Interest] Change QCheckBox to QPushButton in a QTableView
>
...
> >
> > But all I got out of it was a black pixel in the first cell.
>
> You're going to have to do a proper initialization of the
> QStyleOptionButton. At the very least, set the rect it is supposed to be
> drawn in. You can copy that information from the QStyleOptionViewItem.
> You will need to set the checked state from there as well.
But the QStyleOptionButton() class only defines:
* ButtonFeatures features
* QIcon icon
* QSize iconSize
* QString text
And Inherits:
* Qt::LayoutDirection direction
* QFontMetrics fontMetrics
* QPalette palette
* QRect rect
* QStyle::State state
* QObject *styleObject
* int type
* int version
In addition QStyle::State does not have a check state - it's not that kind of state apparently.
I added an assignment of QStypeOptionButton rect from options, and that now shows the text, but the rest of the button is not rendered (Attached). If I use a pushbutton to initialize options I've got to subclass it because initStypeOptions is protected (why?), won't I overwrite the supplied options and then have to merge them back in, how do I know what needs to be preserved from the original options? This whole system seems backwards. My delegate doesn't have a pointer to a widget does it?
This whole setup seems backwards, which is unusual for me with Qt. I can get behind the idea of being passed a painter and rect to render into, but the rest of the API seems like it's making a main use-case extremely difficult. Which usually isn't the case with Qt, so it makes me think I'm doing something very wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2017-12-07 at 9.20.01 AM.png
Type: image/png
Size: 5714 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20171207/ca3f2c54/attachment.png>
More information about the Interest
mailing list