@@ -220,27 +220,26 @@ void CharacterWidget::paintEvent( QPaintEvent *event )
220220 QPainter painter ( this );
221221 painter.setFont ( mDisplayFont );
222222
223+ QFontMetrics fontMetrics ( mDisplayFont );
224+
223225 QRect redrawRect = event->rect ();
224226 int beginRow = redrawRect.top () / mSquareSize ;
225227 int endRow = redrawRect.bottom () / mSquareSize ;
226228 int beginColumn = redrawRect.left () / mSquareSize ;
227229 int endColumn = std::min ( mColumns - 1 , redrawRect.right () / mSquareSize );
228230
229231 QPalette palette = qApp->palette ();
230- QRectF backgroundRect = event->rect ();
231- backgroundRect.setWidth ( std::min ( backgroundRect.width (), ( endColumn + 1 ) * mSquareSize - backgroundRect.left () ) );
232- painter.fillRect ( backgroundRect, QBrush ( palette.color ( QPalette::Base ) ) );
233-
234232 painter.setPen ( QPen ( palette.color ( QPalette::Mid ) ) );
235233 for ( int row = beginRow; row <= endRow; ++row )
236234 {
237235 for ( int column = beginColumn; column <= endColumn; ++column )
238236 {
237+ int key = row * mColumns + column;
238+ painter.setBrush ( fontMetrics.inFont ( QChar ( key ) ) ? QBrush ( palette.color ( QPalette::Base ) ) : Qt::NoBrush );
239239 painter.drawRect ( column * mSquareSize , row * mSquareSize , mSquareSize , mSquareSize );
240240 }
241241 }
242242
243- QFontMetrics fontMetrics ( mDisplayFont );
244243 for ( int row = beginRow; row <= endRow; ++row )
245244 {
246245 for ( int column = beginColumn; column <= endColumn; ++column )
0 commit comments