@@ -208,8 +208,9 @@ void ChameleonStyle::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOpti
208
208
209
209
// QTreeView的绘制复制了QCommonStyle的代码,添加了圆角的处理,hover的处理
210
210
if (qobject_cast<const QTreeView *>(w)) {
211
+ const auto &delegate = *qobject_cast<const QTreeView *>(w)->itemDelegate ();
211
212
// 如果QTreeView使用的不是默认代理 QStyledItemDelegate,则采取DStyle的默认绘制(备注:这里的QtCreator不会有hover效果和圆角)
212
- if (!qobject_cast<QStyledItemDelegate *>(qobject_cast< const QTreeView *>(w)-> itemDelegate () )) {
213
+ if (typeid (delegate) != typeid (QStyledItemDelegate )) {
213
214
break ;
214
215
}
215
216
@@ -269,15 +270,15 @@ void ChameleonStyle::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOpti
269
270
p->setPen (Qt::NoPen);
270
271
p->setBrush (getColor (opt, QPalette::Highlight));
271
272
p->setRenderHint (QPainter::Antialiasing);
272
- p->drawRoundedRect (select_rect. adjusted ( 1 , 1 , - 1 , - 1 ) , frame_radius, frame_radius);
273
+ p->drawRoundedRect (select_rect, frame_radius, frame_radius);
273
274
return ;
274
275
} else {
275
276
if (vopt->backgroundBrush .style () != Qt::NoBrush) {
276
277
p->save ();
277
278
p->setPen (Qt::NoPen);
278
279
p->setBrush (vopt->backgroundBrush );
279
280
p->setRenderHint (QPainter::Antialiasing);
280
- p->drawRoundedRect (opt->rect . adjusted ( 1 , 1 , - 1 , - 1 ) , frame_radius, frame_radius);
281
+ p->drawRoundedRect (opt->rect , frame_radius, frame_radius);
281
282
p->restore ();
282
283
return ;
283
284
}
@@ -575,8 +576,9 @@ void ChameleonStyle::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOpti
575
576
}
576
577
// 这里QTreeView的绘制复制了QCommonStyle的代码,添加了圆角的处理,hover的处理
577
578
if (qobject_cast<const QTreeView *>(w)) {
579
+ const auto &delegate = *qobject_cast<const QTreeView *>(w)->itemDelegate ();
578
580
// 如果QTreeView使用的不是默认代理 QStyledItemDelegate,则采取DStyle的默认绘制(备注:这里的QtCreator不会有hover效果和圆角)
579
- if (!qobject_cast<QStyledItemDelegate *>(qobject_cast< const QTreeView *>(w)-> itemDelegate () )) {
581
+ if (typeid (delegate) != typeid (QStyledItemDelegate )) {
580
582
break ;
581
583
}
582
584
0 commit comments