2014-10-28 112 views
1

我想要子類QStyledItemDelegate並使用QStyleSheets修改它。我沒有任何關於如何讓它工作的線索。我嘗試了很多小時來顯示任何東西,看起來像我在qss中定義的。在priciple它必須工作,因爲當我調用基類實現paint(QPainter*, const QStyleOptionViewItem &, const QModelIndex&)列表項目看起來像定義。那麼,現在我該如何在委託中應用樣式表?如何繪製QStyledItemDelegate中的qStylesheet

回答

0

一切都必須通過QStyle完成。例如。在QListView中繪製背景:

QStyle *style = option.widget->style(); 
style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, option.widget); 

還有很多其他的drawXYZ(..)函數。請參閱QStyle docs