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. Qt Button
Forum Updated to NodeBB v4.3 + New Features

Qt Button

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 3 Posters 566 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.
  • R Rkutun

    Ekran görüntüsü 2025-01-22 103909.png

    Hello,

    I want to create directional buttons like the ones shown in the image I shared. I implemented them using pixmap, but it causes lag on the Raspberry Pi. Could you help me figure out how to design this button structure in a way that won't cause performance issues?

    JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by
    #2

    @Rkutun Is this a touch screen issue? I guess your calculation to find the region from touch position is fast enough.

    R 1 Reply Last reply
    0
    • JoeCFDJ JoeCFD

      @Rkutun Is this a touch screen issue? I guess your calculation to find the region from touch position is fast enough.

      R Offline
      R Offline
      Rkutun
      wrote on last edited by
      #3

      @JoeCFD said in Qt Button:

      @Rkutun Is this a touch screen issue? I guess your calculation to find the region from touch position is fast enough.

      Thank you for your response.

      There is no issue with the touch screen itself. I have tested it with different buttons, and they work without any problems and perform optimally.

      I am using a Raspberry Pi 4 for this project. Could the performance issue be related to the processor speed? I ask this because there is no lag or similar problem when I test the same setup on a computer.

      jsulmJ 1 Reply Last reply
      0
      • R Rkutun

        @JoeCFD said in Qt Button:

        @Rkutun Is this a touch screen issue? I guess your calculation to find the region from touch position is fast enough.

        Thank you for your response.

        There is no issue with the touch screen itself. I have tested it with different buttons, and they work without any problems and perform optimally.

        I am using a Raspberry Pi 4 for this project. Could the performance issue be related to the processor speed? I ask this because there is no lag or similar problem when I test the same setup on a computer.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @Rkutun You will have to provide more information about your implementation. Optimally show the code.

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

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Rkutun
          wrote on last edited by
          #5

          Thank you for your response.

          The code I am using is as follows:

          QPixmap pixmap(":/new/prefix1/icons/a.png");
          if (pixmap.isNull()) {
          qDebug() << "Pixmap failed to load!";
          return;
          }

          QBitmap bitmap = pixmap.createMaskFromColor(Qt::white, Qt::MaskInColor);
          if (bitmap.isNull()) {
             qDebug() << "Could not create mask!";
             return;
          }
          
          QBitmap scaledBitmap = QBitmap::fromPixmap(bitmap.scaled(ui->nozzleLeft10mmBtn->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
          

          ui->LeftBtn->setMask(scaledBitmap);
          ui->LeftBtn->update();

          jsulmJ 1 Reply Last reply
          0
          • R Rkutun

            Thank you for your response.

            The code I am using is as follows:

            QPixmap pixmap(":/new/prefix1/icons/a.png");
            if (pixmap.isNull()) {
            qDebug() << "Pixmap failed to load!";
            return;
            }

            QBitmap bitmap = pixmap.createMaskFromColor(Qt::white, Qt::MaskInColor);
            if (bitmap.isNull()) {
               qDebug() << "Could not create mask!";
               return;
            }
            
            QBitmap scaledBitmap = QBitmap::fromPixmap(bitmap.scaled(ui->nozzleLeft10mmBtn->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
            

            ui->LeftBtn->setMask(scaledBitmap);
            ui->LeftBtn->update();

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @Rkutun It is not clear where you're executing this code. It is also not clear what you're doing when one of the buttons is clicked.
            Please format your code correctly.

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

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Rkutun
              wrote on last edited by
              #7

              Thank you for your response.

              I have not added any specific functionality to the button. It only lags when the button is in the pressed state.

              Additionally, I have another button next to it where I rotate an image, and it works smoothly. However, when I press the button with the pixmap, the image freezes.

              Could you provide any suggestions to resolve this issue?

              jsulmJ 1 Reply Last reply
              0
              • R Rkutun

                Thank you for your response.

                I have not added any specific functionality to the button. It only lags when the button is in the pressed state.

                Additionally, I have another button next to it where I rotate an image, and it works smoothly. However, when I press the button with the pixmap, the image freezes.

                Could you provide any suggestions to resolve this issue?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @Rkutun "It is not clear where you're executing this code." - you did not answer this...

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

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Rkutun
                  wrote on last edited by
                  #9

                  Thank you for your response.

                  Could you please clarify what exactly you are asking about? Are you referring to the context in which the code is executed, such as whether it's within a specific function, event handler, or somewhere else? I want to make sure I provide the exact information you need.

                  jsulmJ 1 Reply Last reply
                  0
                  • R Rkutun

                    Thank you for your response.

                    Could you please clarify what exactly you are asking about? Are you referring to the context in which the code is executed, such as whether it's within a specific function, event handler, or somewhere else? I want to make sure I provide the exact information you need.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @Rkutun said in Qt Button:

                    Are you referring to the context in which the code is executed

                    Yes.

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

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      Rkutun
                      wrote on last edited by
                      #11

                      Thank you for your response.

                      The code is not triggered by any specific event or function. It is not part of any separate function or event handler. I am directly running it within the MainWindow class during its initialization.

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        Rkutun
                        wrote on last edited by
                        #12

                        Help please!!!

                        jsulmJ 1 Reply Last reply
                        0
                        • R Rkutun

                          Help please!!!

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #13

                          @Rkutun Try to profile your app on the device to see where it spends most time when the button lags.

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

                          1 Reply Last reply
                          0
                          • R Offline
                            R Offline
                            Rkutun
                            wrote on last edited by
                            #14

                            Thank you for your suggestion.

                            Could you guide me on how to profile the application to analyze where the lag occurs? I would appreciate any tools or steps you recommend to perform this process effectively.

                            jsulmJ 1 Reply Last reply
                            0
                            • R Rkutun

                              Thank you for your suggestion.

                              Could you guide me on how to profile the application to analyze where the lag occurs? I would appreciate any tools or steps you recommend to perform this process effectively.

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #15

                              @Rkutun Take a look at https://ftp.gnu.org/old-gnu/Manuals/gprof-2.9.1/html_mono/gprof.html

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

                              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