Correct the position of the colored rectangle in ColorEditor and ColorDelegate

This commit is contained in:
Stanislav Bas 2015-06-17 00:45:43 +03:00
parent 850f612c8b
commit ed09424223
2 changed files with 8 additions and 8 deletions

View file

@ -25,10 +25,10 @@ void CSVWidget::ColorEditor::paintEvent(QPaintEvent *event)
QPushButton::paintEvent(event);
QRect buttonRect = rect();
QRect coloredRect(qRound(buttonRect.x() + buttonRect.width() / 4.0),
qRound(buttonRect.y() + buttonRect.height() / 4.0),
qRound(buttonRect.width() / 2.0),
qRound(buttonRect.height() / 2.0));
QRect coloredRect(buttonRect.x() + qRound(buttonRect.width() / 4.0),
buttonRect.y() + qRound(buttonRect.height() / 4.0),
buttonRect.width() / 2,
buttonRect.height() / 2);
QPainter painter(this);
painter.fillRect(coloredRect, mColor);
painter.setPen(Qt::black);

View file

@ -15,10 +15,10 @@ void CSVWorld::ColorDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QRect coloredRect(qRound(option.rect.x() + option.rect.width() / 4.0),
qRound(option.rect.y() + option.rect.height() / 4.0),
qRound(option.rect.width() / 2.0),
qRound(option.rect.height() / 2.0));
QRect coloredRect(option.rect.x() + qRound(option.rect.width() / 4.0),
option.rect.y() + qRound(option.rect.height() / 4.0),
option.rect.width() / 2,
option.rect.height() / 2);
painter->save();
painter->fillRect(coloredRect, index.data().value<QColor>());
painter->setPen(Qt::black);