Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Raspberry PI Zero Qt GUI Animation too Slow rendering performance



  • Hi:

    I have using the Qt by cross compilation method by this site instruction by this configuration:

    ./configure -release -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -skip qtwayland -skip qtlocation -skip qtscript -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -no-use-gold-linker -v -no-gbm
    

    So when I added this project to my raspberry the rendering of it take too long.

    mainwindow.cpp

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QGridLayout>
    #include <QWidget>
    #include <QMovie>
    
    
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow),
        newButton(new QPushButton("Button 3"))
    {
        ui->setupUi(this);
        const int rowNumber = 1;
        const int colNumber = 0;
        //newButton->styleSheet() "background-color:green";
    
       //ui->gridLayout->addWidget(newButton, rowNumber, colNumber);
    
    
        auto movie = new QMovie(this);
        movie->setFileName(":/Pictures/70a552e8e955049c8587b2d7606cd6a6.gif");
        connect(movie, &QMovie::frameChanged, [=]{
             ui->pushButton_4->setIcon(movie->currentPixmap());
        });
        ui->pushButton_4->setIconSize(QSize(220,220));
        movie->start();
    
        QWidget *datawidget = new QWidget( this );
        //ui->setCentralWidget( datawidget );
        datawidget->setAccessibleName("datawidget");
        datawidget->setStyleSheet(" #datawidget { background-color:#000; } ");
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::on_pushButton_clicked()
    {
    
    }
    
    void MainWindow::on_pushButton_2_clicked()
    {
    
    }
    

    And

    mainwindow.ui

        <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <class>MainWindow</class>
     <widget class="QMainWindow" name="MainWindow">
      <property name="enabled">
       <bool>true</bool>
      </property>
      <property name="geometry">
       <rect>
        <x>0</x>
        <y>0</y>
        <width>800</width>
        <height>480</height>
       </rect>
      </property>
      <property name="sizePolicy">
       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
        <horstretch>10</horstretch>
        <verstretch>10</verstretch>
       </sizepolicy>
      </property>
      <property name="mouseTracking">
       <bool>true</bool>
      </property>
      <property name="tabletTracking">
       <bool>true</bool>
      </property>
      <property name="windowTitle">
       <string>MainWindow</string>
      </property>
      <property name="styleSheet">
       <string notr="true">background-image: url(:/Pictures/logo3.gif);
    background-color: rgb(0, 0, 0);</string>
      </property>
      <property name="iconSize">
       <size>
        <width>100</width>
        <height>100</height>
       </size>
      </property>
      <widget class="QWidget" name="centralWidget">
       <widget class="QPushButton" name="pushButton_2">
        <property name="geometry">
         <rect>
          <x>600</x>
          <y>210</y>
          <width>121</width>
          <height>111</height>
         </rect>
        </property>
        <property name="styleSheet">
         <string notr="true">border-image: url(:/Pictures/nero_smart_start.png);</string>
        </property>
        <property name="text">
         <string/>
        </property>
       </widget>
       <widget class="QPushButton" name="pushButton_3">
        <property name="geometry">
         <rect>
          <x>70</x>
          <y>200</y>
          <width>121</width>
          <height>111</height>
         </rect>
        </property>
        <property name="styleSheet">
         <string notr="true">border-image: url(:/Pictures/images2.gif);</string>
        </property>
        <property name="text">
         <string/>
        </property>
       </widget>
       <widget class="QPushButton" name="pushButton">
        <property name="enabled">
         <bool>true</bool>
        </property>
        <property name="geometry">
         <rect>
          <x>40</x>
          <y>10</y>
          <width>16</width>
          <height>16</height>
         </rect>
        </property>
        <property name="text">
         <string>PushButton</string>
        </property>
        <property name="iconSize">
         <size>
          <width>0</width>
          <height>0</height>
         </size>
        </property>
       </widget>
       <widget class="QPushButton" name="pushButton_4">
        <property name="geometry">
         <rect>
          <x>270</x>
          <y>210</y>
          <width>261</width>
          <height>211</height>
         </rect>
        </property>
        <property name="styleSheet">
         <string notr="true"/>
        </property>
        <property name="text">
         <string/>
        </property>
       </widget>
      </widget>
      <widget class="QMenuBar" name="menuBar">
       <property name="geometry">
        <rect>
         <x>0</x>
         <y>0</y>
         <width>800</width>
         <height>22</height>
        </rect>
       </property>
       <widget class="QMenu" name="menud">
        <property name="title">
         <string>d</string>
        </property>
       </widget>
       <addaction name="menud"/>
      </widget>
      <widget class="QStatusBar" name="statusBar"/>
      <action name="actionss">
       <property name="checkable">
        <bool>true</bool>
       </property>
       <property name="icon">
        <iconset>
         <normaloff>:/Pictures/ss.png</normaloff>:/Pictures/ss.png</iconset>
       </property>
       <property name="text">
        <string>ss</string>
       </property>
       <property name="toolTip">
        <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/Pictures/ss.png&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
       </property>
       <property name="shortcut">
        <string>Ctrl+C</string>
       </property>
      </action>
     </widget>
     <layoutdefault spacing="6" margin="11"/>
     <tabstops>
      <tabstop>pushButton</tabstop>
      <tabstop>pushButton_2</tabstop>
      <tabstop>pushButton_3</tabstop>
     </tabstops>
     <resources/>
     <connections>
      <connection>
       <sender>pushButton_2</sender>
       <signal>clicked()</signal>
       <receiver>MainWindow</receiver>
       <slot>close()</slot>
       <hints>
        <hint type="sourcelabel">
         <x>670</x>
         <y>310</y>
        </hint>
        <hint type="destinationlabel">
         <x>513</x>
         <y>273</y>
        </hint>
       </hints>
      </connection>
      <connection>
       <sender>pushButton_3</sender>
       <signal>clicked()</signal>
       <receiver>MainWindow</receiver>
       <slot>close()</slot>
       <hints>
        <hint type="sourcelabel">
         <x>132</x>
         <y>284</y>
        </hint>
        <hint type="destinationlabel">
         <x>162</x>
         <y>182</y>
        </hint>
       </hints>
      </connection>
     </connections>
    </ui>
    

    The animation gif is :
    alt text

    ANd the rendering in raspberry is :

    alt text

    So i use eglfs and opengl plugins at somewhere I have seen maybe it could be related to this setting.

    What can I do to show videos in my raspberry qt applications as the references rates?

    My other question link:

    https://raspberrypi.stackexchange.com/questions/99919/raspberry-pi-zero-qt-gui-animation-too-slow-rendering-performance

    Thanks


  • Moderators

    Whether you use OpenGL and eglfs or not does not matter here at all - you are using QtWidgets (which are drawn using CPU, not GPU) and you are displaying a GIF animation (which is rendered by CPU, not GPU). My guess is that RPi Zero is just too weak to handle this task.

    Maybe try displaying the movie in some other format, which might be hardware-accelerated on Raspberry (not sure if Zero model has acceleration for any format).


Log in to reply