Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

321
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda