Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Size of text rectangles not calculated correctly #19

Closed
Ebiroll opened this issue Apr 18, 2019 · 4 comments
Closed

Size of text rectangles not calculated correctly #19

Ebiroll opened this issue Apr 18, 2019 · 4 comments
Labels

Comments

@Ebiroll
Copy link

Ebiroll commented Apr 18, 2019

image
As you can see from image the width of the texts are not correct.

I just try to set the document from a file.
QHexView *pcntwgt = dynamic_cast<QHexView >(centralWidget());
QHexDocument
document = QHexDocument::fromFile(fileName);
pcntwgt->setDocument(document);

@Ebiroll
Copy link
Author

Ebiroll commented Apr 18, 2019

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);

@Dax89
Copy link
Owner

Dax89 commented Apr 18, 2019

It looks like a Qt bug:

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!

@Dax89 Dax89 added the bug label Apr 18, 2019
@Ebiroll
Copy link
Author

Ebiroll commented Apr 19, 2019

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....

@Ebiroll Ebiroll closed this as completed Apr 19, 2019
@Ebiroll
Copy link
Author

Ebiroll commented Apr 19, 2019

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();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants