elcuco
29th March 2008, 16:27
I am playing with QTextEdit::cursorRect() and having problems. On large fonts, the rect returned to me is wrong, or I am just using this function badly. My code is basically:
// p is a QPainter
charWidth = p.fontMetrics().width( charStart );
cursor.setPosition(matchStart, QTextCursor::MoveAnchor);
r = cursorRect( cursor );
p.fillRect( r.x()+charWidth, r.y(), charWidth, r.height(), matchBracesColor );
and this is not always working (see attached image). I am also attaching a small application which reproduces this problem (the app is tested under linux only, but should work on windows). Read the header of the file for compilation instructions. The code also contains a few font definitions which work or not.
So... what am I missing here...? :)
// p is a QPainter
charWidth = p.fontMetrics().width( charStart );
cursor.setPosition(matchStart, QTextCursor::MoveAnchor);
r = cursorRect( cursor );
p.fillRect( r.x()+charWidth, r.y(), charWidth, r.height(), matchBracesColor );
and this is not always working (see attached image). I am also attaching a small application which reproduces this problem (the app is tested under linux only, but should work on windows). Read the header of the file for compilation instructions. The code also contains a few font definitions which work or not.
So... what am I missing here...? :)