Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Solved] Performance QLabel

    General and Desktop
    2
    3
    3291
    Loading More Posts
    • 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
      ephe last edited by

      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 Reply Quote 0
      • P
        Peleron last edited by

        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 Reply Quote 0
        • E
          ephe last edited by

          That improved the performance a lot. Thank you!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post