ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccColorStyledDelegate.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include "../include/ccColorStyledDelegate.h"
9 
10 // QT
11 #include <QPainter>
12 
14  : QStyledItemDelegate(parent) {}
15 
16 void ccColorStyledDelegate::paint(QPainter* painter,
17  const QStyleOptionViewItem& option,
18  const QModelIndex& index) const {
19  if (painter && index.model()) {
20  QColor color =
21  index.model()->data(index, Qt::DisplayRole).value<QColor>();
22  painter->fillRect(option.rect, color);
23  }
24 }
math::float4 color
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
ccColorStyledDelegate(QObject *parent=nullptr)