Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFontMetrics::boundingRect is two times slower than QPainter::drawText

QFontMetrics::boundingRect is two times slower than QPainter::drawText

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 228 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dmitriano
    wrote on last edited by Dmitriano
    #1

    In my app I draw a table with 1000+ strings from beforeRendering() haldler:

    void LightGrid::beforeRendering()
    {
        const QSize window_size = window()->size();
        QOpenGLPaintDevice device(window_size);
        QPainter painter(&device);
        ...
        //Measure the strings with QFontMetrics::boundingRect
        //Draw the strings with QPainter::drawText
    }
    

    MSVC 2017 profiler shows that QFontMetrics::boundingRect is two times slower than QPainter::drawText in my app.

    Is there a way to replace QFontMetrics::boundingRect with something that works faster?

    My QT version is 5.15.0, OS: Windows 10

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Since those two functions do completely different things - no. But the Qt source code is freely available so you can take a look if you can improve it's performance.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved