30 #include <QMouseEvent> 41 setMouseTracking(
true);
58 m_font.setFamily(font.family());
64 QPoint widgetPosition = mapFromGlobal(e->globalPos());
67 QString text = QString::fromUtf8(
"<p>Char: <span style=\"font-size: 28pt; font-family: %1\">").arg(
m_font.family())
69 + QString::fromUtf8(
"</span><p>Value: 0x")
70 + QString::number(key, 16);
72 QToolTip::showText(e->globalPos(), text,
this);
77 if(e->button() != Qt::LeftButton)
79 QWidget::mousePressEvent(e);
84 #if (QT_VERSION >= 0x050000) 85 if(QChar(
m_currentChar).category() != QChar::Other_NotAssigned)
96 QPainter painter(
this);
97 painter.fillRect(e->rect(), Qt::white);
100 QRect redrawRect = e->rect();
106 painter.setPen(Qt::gray);
107 for(
int row = beginRow; row <= endRow; ++row)
108 for(
int column = beginColumn; column <= endColumn; ++column)
109 painter.drawRect(column *
m_squareSize, row * m_squareSize, m_squareSize, m_squareSize);
111 painter.setPen(Qt::black);
112 QFontMetrics fontMetrics(
m_font);
113 for(
int row = beginRow; row <= endRow; ++row)
115 for(
int column = beginColumn; column <= endColumn; ++column)
118 painter.setClipRect(column * m_squareSize, row * m_squareSize, m_squareSize, m_squareSize);
121 painter.fillRect(column * m_squareSize + 1, row * m_squareSize + 1, m_squareSize, m_squareSize, Qt::lightGray);
123 painter.drawText(column * m_squareSize + (m_squareSize / 2) - fontMetrics.width(QChar(key))/2,
124 row * m_squareSize + 4 + fontMetrics.ascent(),
125 QString(QChar(key)));