So is there a way to access stylesheet data from within QStyledItemDelegate? The painting/measuring methods of QStyle do access it. But I didn't see any way to do it myself neither using QStyle nor QStyleOptionViewItem.
So is there a way to access stylesheet data from within QStyledItemDelegate? The painting/measuring methods of QStyle do access it. But I didn't see any way to do it myself neither using QStyle nor QStyleOptionViewItem.
No, what sense would it make? QStyledItemDelegate will respect your stylesheet by itself if you remember to call the base class implementation in your subclass.
That way I could set up some styles which I would then query for myself (in item delegate) and use them in painting operation. Now I cannot (for model/view items) - or better to say I'm very limited in my options. If I would like to use border-image for fancier (stretched) background in normal, alternate and selected modes then its all fine. But if my items have another "mode" like for example "erroneous" with red background then how should I proceed? Since as for now I can see just one option: throw away the stylesheet and embed everything in item delegate.
Actually this is what I was advised to do by my co-workers. But I found it hard to believe that it cannot be done with stylesheets as main "style" source.
(The border-image example is not just a sample. QStyleOptionViewItem don't seem to provide means to set/overwrite border-image. It only allow to set background brush. Which will be then cheerfully overpainted with the border-image that comes from stylesheet...)
Well, you can query whatever you want. The stylesheet is available in the stylesheet property of the widget, its parent, etc. But there is no cascading and no parsing. You have to do everything manually. Of course you can store a stylesheet for each item separately in the model and then parse it and do whatever you want with it.
I already told you that implementing border-image in C++ is 9 lines of code (or less).Now I cannot (for model/view items) - or better to say I'm very limited in my options. If I would like to use border-image for fancier (stretched) background in normal, alternate and selected modes then its all fine. But if my items have another "mode" like for example "erroneous" with red background then how should I proceed? Since as for now I can see just one option: throw away the stylesheet and embed everything in item delegate.
If all you want from style sheets is image-border, then drop the stylesheet and paint the image in the delegate the way you want it.Actually this is what I was advised to do by my co-workers. But I found it hard to believe that it cannot be done with stylesheets as main "style" source.
Bookmarks