Add background to the drag&drop pixmap to make it better readable.

master
Torsten Paul 2014-12-23 18:42:16 +01:00
parent 481665f8a3
commit 0801fc432d
1 changed files with 3 additions and 2 deletions

View File

@ -50,13 +50,14 @@ void FontListTableView::startDrag(Qt::DropActions supportedActions)
mimeData->setText(text);
QFontMetrics fm(font());
QRect rect(0, 0, fm.width(text), fm.height());
QRect rect(0, 0, fm.width(text) + 8, fm.height() + 8);
QPixmap pixmap(rect.width(), rect.height());
pixmap.fill(Qt::transparent);
pixmap.fill(QColor(240, 240, 240, 160));
QPainter painter(&pixmap);
painter.setFont(font());
painter.drawText(rect, Qt::AlignCenter, text);
painter.drawRect(0, 0, rect.width() - 1, rect.height() - 1);
QDrag *drag = new QDrag(this);
drag->setPixmap(pixmap);