Qt Forum

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

    Solved [Solved] Scrolling Text eating lot of CPU on beagleBone

    Mobile and Embedded
    4
    25
    6070
    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.
    • G
      guru007 last edited by guru007

      I am using QTextEdit to show Scrolling text by setting
      ui->textEdit->setvalue(count);
      count ++;

      When I am running on my i5 PC it is running smoothely but When I run it on Beaglebone, There are two scenerios:
      1.With Eglfs platform plugin, It is scrolling very slowly and jerky but less CPU consumption.
      2.With linuxFb plugin, It is scrolling almost like PC but CPU goes over 100 %.

      What Should I Do to solve the problem?

      1 Reply Last reply Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        Do you need rich text? Consider using QPlainTextEdit otherwise.

        QTextEdit does not have setValue() method. Are you sure you are using it?

        You can try using scrollContentsBy() instead. It is protected, though, so you would have to expose the method in a custom subclass.

        (Z(:^

        1 Reply Last reply Reply Quote 1
        • G
          guru007 last edited by

          I don't need rich text. I implemented in this way:
          QScrollBar sb;
          sb = ui->message->verticalScrollBar();
          sb.setValue(count);

          1 Reply Last reply Reply Quote 0
          • sierdzio
            sierdzio Moderators last edited by

            verticalScrollBar() returns a pointer so what you posted will not compile. It may be just that certain platform pluggins work sluggishly here. I would still recommend trying with QPlainTextEdit and scrollContentsBy() (or even QWidget::move() could work). If you compare how these various techniques work, you can pinpoint the fastest one and use it.

            (Z(:^

            1 Reply Last reply Reply Quote 1
            • G
              guru007 last edited by

              I used pointer like
              QScrollBar *sb;
              sb = ui->message->verticalScrollBar();
              sb->setValue(count);

              But I want to know why it is very slow on Beaglebone device.
              Please suggest me If I use ScrollContentsBy() then Is there any performance gains.
              Can I use hardware acceleration for Text rendering?

              1 Reply Last reply Reply Quote 0
              • sierdzio
                sierdzio Moderators last edited by

                Please suggest me If I use ScrollContentsBy() then Is there any performance gains.

                I don't know. I've given you options to try out, they may help you or may turn out to be rubbish. I don't have time to check them out myself for you, sorry.

                You can also try other things which could impact performance: set the text edit to read-only mode, for example (at least for the duration of scrolling).

                You can also ask on Qt Interest mailing list - a lot of Qt deveopers (that is, people developing Qt itself) are active there, they could have some more accurate hints for you (possibly related to platform support, too).

                Can I use hardware acceleration for Text rendering?

                As far as I know, no, widgets are painted by Qt raster engine (which on most platforms seems faster than OpenGL).

                (Z(:^

                1 Reply Last reply Reply Quote 1
                • SGaist
                  SGaist Lifetime Qt Champion last edited by

                  Hi,

                  What kind of text are you showing ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply Reply Quote 1
                  • G
                    guru007 last edited by

                    Hi SGaist,
                    I am using simple text in english with a .ttf font which I am using from resource file. There is one suggestion I received from my Qt friend that If I create QImage from text using QPainter and then scroll the QImage, Then it will solve my Problem.Any suggestions from ur side Please.

                    1 Reply Last reply Reply Quote 0
                    • G
                      guru007 last edited by

                        QFont font1;
                          font1.setBold(true);
                          font1.setFamily("Sans Serif");
                          font1.setPointSize(100);
                          QImage image(1024,768, QImage::Format_ARGB32_Premultiplied);
                          QPainter painter(&image);
                          painter.fillRect(image.rect(), Qt::yellow);
                          painter.setFont(font1);
                          painter.drawText(image.rect(), Qt::AlignCenter | Qt::AlignVCenter, "hello, world");
                          scene = new QGraphicsScene(this);
                          scene->addPixmap(QPixmap::fromImage(image));
                          scene->setSceneRect(image.rect());
                          ui->mainImage->setScene(scene);
                      

                      Now I am experimenting with QGraphicsScene but when I scroll frequently with mouse in QScrollArea, then Cpu reaches 100 %.

                      1 Reply Last reply Reply Quote 0
                      • SGaist
                        SGaist Lifetime Qt Champion last edited by

                        So a fixed text. How big is it ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply Reply Quote 1
                        • G
                          guru007 last edited by

                          I am receiving text from Uart. SO it can be of very long length.
                          That is why there is need of scrolling because text size is very large (point size 200)
                          Actually It is passenger information display showing train information to passengers on LCD.

                          1 Reply Last reply Reply Quote 0
                          • SGaist
                            SGaist Lifetime Qt Champion last edited by

                            Looks like you should rather consider a QListView using a QStringListModel.

                            Also, how big is the history that you want to keep available to your passengers ?

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply Reply Quote 1
                            • G
                              guru007 last edited by

                              Thanks for suggestions, But I think problem is graphics performance on Beaglebone black.
                              I think application not using hardware acceleration for rendering of scrolling text because text is refreshed at 100 times per second because I scrolling text by incrementing :
                              QTimer timer;
                              timer.setInterval(5);
                              timer-> connected with Slot()
                              Slot()
                              {
                              static int count = 0;
                              scrollbar->setValue(count);
                              count ++;
                              }

                              Basically When I using other Qt Demo apps like colliding mice CPU usage increases to 100%.
                              BeagleBone black SGX GPU for graphics. Is there anything to do or How can I check whether GPU is used or not By Qt application.
                              Thanks

                              jsulm 2 Replies Last reply Reply Quote 0
                              • jsulm
                                jsulm Lifetime Qt Champion @guru007 last edited by

                                @guru007 said in Scrolling Text eating lot of CPU on beagleBone:

                                text is refreshed at 100 times per second

                                this does not make sense as your display most probably cannot refresh so often (usually it is 60Hz). Actually it would be enough to refresh at 25Hz - this is what a human perceives as smooth.

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                G 1 Reply Last reply Reply Quote 1
                                • G
                                  guru007 @jsulm last edited by SGaist

                                  @jsulm
                                  But with even 30 fps it consuming whole processing Power.

                                  1 Reply Last reply Reply Quote 0
                                  • jsulm
                                    jsulm Lifetime Qt Champion @guru007 last edited by SGaist

                                    @guru007 Sorry, something went wrong here and I edited your last post. That wasn't intentionally.

                                    You wrote before that the text can be very long. You should test with not so long text (but still long enough to need a scroll bar). Does it then still consume 100% CPU?
                                    Qt widgets do not use hardware acceleration as far as I know (but QML does). Alternative would be to use http://doc.qt.io/qt-5/graphicsview.html

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    1 Reply Last reply Reply Quote 1
                                    • SGaist
                                      SGaist Lifetime Qt Champion last edited by

                                      @jsulm Everything is back on track. I still had the email from the thread :)

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      jsulm 1 Reply Last reply Reply Quote 2
                                      • jsulm
                                        jsulm Lifetime Qt Champion @SGaist last edited by

                                        @SGaist Thanks!

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        G 1 Reply Last reply Reply Quote 2
                                        • G
                                          guru007 @jsulm last edited by

                                          @jsulm How can I check If my application uses GPU for rendering. I read from stackoverflow:

                                          Qt doesn't magically GPU-accelerate the entire application. Widgets are not accelerated unless they derive from QOpenGLWidget. Qt Quick 2 is accelerated by default; there's an option of using the software renderer on hardware that doesn't support OpenGL ES 2. Qt Quick 1 is accelerated if you set a QOpenGLWidget as a viewport on the QGraphicsView.

                                          Could you suggest some already built app to test gpu? Some Demo app

                                          jsulm 1 Reply Last reply Reply Quote 0
                                          • jsulm
                                            jsulm Lifetime Qt Champion @guru007 last edited by

                                            @guru007 If you use widgets there is nothing to check as those do not use GPU.

                                            https://forum.qt.io/topic/113070/qt-code-of-conduct

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