Size of text rectangles not calculated correctly
Ebiroll opened this issue · 4 comments
OK, So maybe it is a font issue on Linux.
I solved the issue with this patch.
QHexView::QHexView(QWidget *parent) : QAbstractScrollArea(parent), m_document(NULL), m_renderer(NULL), m_readonly(false)
{
//this->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
QFont font("Monospace");
font.setStyleHint(QFont::TypeWriter);
this->setFont(font);
It looks like a Qt bug:
- https://forum.qt.io/topic/95826/qfontdatabase-doesn-t-give-me-a-fixed-font-lubuntu-18-10/4
- https://bugreports.qt.io/browse/QTBUG-54623
The workaround is more or less the one posted by you:
if (fixedFont.fixedPitch() == false) { // workaround for QTBUG-54623
fixedFont.setFamily("monospace");
}
I can add it to the widget...thanks for reporting!
OK. It looks like it fixed the Issue.
It would be good to have some simple examples for this widget.
i.e. I am trying to set the cursor to an offset.
QHexView *pcntwgt = dynamic_cast<QHexView *>(centralWidget());
QHexCursor* cur = pcntwgt->document()->cursor();
int reminder=offset%16;
cur->moveTo(offset/16,reminder,0);
Does not work. :-( Maybe some kind of repaint() is required....
Actually,
I added an emit positionChanged(); in the QHexCursor::moveTo function, then it worked as I expected.
void QHexCursor::moveTo(int line, int column, int nibbleindex)
{
...
emit positionChanged();
}