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. [Solved] Performance QLabel

[Solved] Performance QLabel

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.6k 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.
  • E Offline
    E Offline
    ephe
    wrote on last edited by
    #1

    I'm trying to test the performance of the text drawing of Qt.

    In our application we need to update up to 10 values around every 200 ms.
    Therefore I created a test application which consists of 32 Labels aligned in a GridLayout (which is set to the central widget of the main window). They are updated with random values every 200 ms.

    @
    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(UpdateLabel()));
    timer->start(200);
    @

    @
    void MainWindow::UpdateLabel()
    {
    m_poLabel1->setText(QString("%1").arg(rand()));
    //....
    }
    @

    Now the CPU loads seem to be quite high, when I draw it with OpenGL, it the CPU 1 load is around 20, the CPU 2 load is around 35.
    When drawing it with the raster engine, the CPU 1 load is around 10, the CPU 2 load is around 45.

    I replaced the QLabels with an own widget which holds a QStaticText (even though it says in the documentation that this should be used when the text and its layout is updated rarely). But the CPU 1 load is around 17 and the CPU 2 load is around 25.

    Now I wanted to know if there is a way of improving the performance of the drawing of the texts?

    If you need some further information or more code please tell me.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Peleron
      wrote on last edited by
      #2

      May be each change of labels text invoke recalculation positions of all other QLabels, because GridLayout adjust cells width.
      Try to set fixed size of QLabel's

      1 Reply Last reply
      0
      • E Offline
        E Offline
        ephe
        wrote on last edited by
        #3

        That improved the performance a lot. Thank you!

        1 Reply Last reply
        0

        • Login

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