Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

325
Visualizações
Bad Performance of QPainter::drawText on Linux

I have noticed that QPainter::drawText is horribly slow on Linux when using it with a scaled window mapping. Is there anything I can do about this? I already checked whether disabling anti-aliasing or enabled the raster-renderer makes a difference, but it doesn't.

Example: When using a viewport size of (450px, 200px), a window size of factor 100 (45000, 20000) and thus font sizes scaled up by factor 100 as well (1400pt), rendering 30 times the text "hello" takes about 4(!) seconds on Linux - both on OpenSuse and Ubuntu.

The same sample renders in a snap on Windows and Mac.

Just for clarification: although the font size is scaled up, the text appears in "normal" size on screen due to the described window<->viewport mapping.

Here is the simple sample code I am using:

void Widget::paintEvent(QPaintEvent *event)
{
    const int scaleFactor = 100;

    QPainter painter(this);

    // Setup font
    QFont font;
    font.setPointSize(14*scaleFactor);
    painter.setFont(font);

    // Setup mapping
    painter.setWindow(0, 0, width() * scaleFactor, height() * scaleFactor);

    // Render the text
    for (int i = 0; i < 30; i++)
        painter.drawText(qrand() % (width() * scaleFactor), qrand() % (height() * scaleFactor), "Hello");
}

Any help would be awesome.

Note: I am using Qt 4.8.5

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

This question is quite old but as be Qt bug still seems to be unresolved here we go...

Not sure if this might be an option but in two projects I worked for we implemented labels which internally rendered into a pimap/image first which was then drawn. So caching your text in an image whith transparent background should solve the problem.

I do not think it makes a difference here, but you might also check if QStaticText has a beneficial influence on performance in your case.

over 4 years ago · Santiago Trujillo Relatório

0

Problem found!

The FontConfig developer libraries where not installed on my Linux system. This caused Qt to be built against XLFD, which obviously doesn't work well with scaled mappings (see report above).

After installing the FontConfig dev libs and rebuilding Qt the text now gets rendered nice and fast. I did additionally specify the "-fontconfig" parameter when rebuilding Qt, just to be sure, but according to the Qt guys this shouldn't be necessary.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda