@@ -774,9 +774,15 @@ void RDTreeView::drawBranches(QPainter *painter, const QRect &rect, const QModel
774
774
opt.rect = allLinesRect;
775
775
opt.showDecorationSelected = true ;
776
776
opt.backgroundBrush = index.data (Qt::BackgroundRole).value <QBrush>();
777
- QColor foreCol = index.data (Qt::ForegroundRole).value <QBrush>().color ();
778
- opt.palette .setColor (QPalette::Foreground, foreCol);
779
- opt.palette .setColor (QPalette::Text, foreCol);
777
+ QVariant foreColVar = index.data (Qt::ForegroundRole);
778
+ QColor foreCol;
779
+
780
+ if (foreColVar.isValid ())
781
+ {
782
+ foreCol = foreColVar.value <QBrush>().color ();
783
+ opt.palette .setColor (QPalette::Foreground, foreCol);
784
+ opt.palette .setColor (QPalette::Text, foreCol);
785
+ }
780
786
781
787
style ()->drawPrimitive (QStyle::PE_PanelItemViewItem, &opt, painter, this );
782
788
@@ -786,7 +792,8 @@ void RDTreeView::drawBranches(QPainter *painter, const QRect &rect, const QModel
786
792
{
787
793
// set the desired colour for RDTweakedNativeStyle via a huge hack - see
788
794
// RDTweakedNativeStyle::drawPrimitive for QStyle::PE_IndicatorBranch
789
- painter->setPen (QPen (foreCol, 1234.5 ));
795
+ if (foreColVar.isValid ())
796
+ painter->setPen (QPen (foreCol, 1234.5 ));
790
797
QTreeView::drawBranches (painter, rect, index);
791
798
}
792
799
else
0 commit comments