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 657 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
    22 Jan 2025, 08:21

    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?

    J Offline
    J Offline
    JoeCFD
    wrote on 22 Jan 2025, 13:27 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 23 Jan 2025, 05:19
    0
    • J JoeCFD
      22 Jan 2025, 13:27

      @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 23 Jan 2025, 05:19 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.

      J 1 Reply Last reply 23 Jan 2025, 06:06
      0
      • R Rkutun
        23 Jan 2025, 05:19

        @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.

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 23 Jan 2025, 06:06 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 23 Jan 2025, 06:28 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();

          J 1 Reply Last reply 23 Jan 2025, 06:30
          0
          • R Rkutun
            23 Jan 2025, 06:28

            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();

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 23 Jan 2025, 06:30 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 23 Jan 2025, 06:40 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?

              J 1 Reply Last reply 23 Jan 2025, 06:42
              0
              • R Rkutun
                23 Jan 2025, 06:40

                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?

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 23 Jan 2025, 06:42 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 23 Jan 2025, 06:51 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.

                  J 1 Reply Last reply 23 Jan 2025, 07:18
                  0
                  • R Rkutun
                    23 Jan 2025, 06:51

                    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.

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 23 Jan 2025, 07:18 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 23 Jan 2025, 09:56 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 23 Jan 2025, 14:04 last edited by
                        #12

                        Help please!!!

                        J 1 Reply Last reply 24 Jan 2025, 06:23
                        0
                        • R Rkutun
                          23 Jan 2025, 14:04

                          Help please!!!

                          J Offline
                          J Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on 24 Jan 2025, 06:23 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 24 Jan 2025, 12:00 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.

                            J 1 Reply Last reply 24 Jan 2025, 12:19
                            0
                            • R Rkutun
                              24 Jan 2025, 12:00

                              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.

                              J Offline
                              J Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on 24 Jan 2025, 12:19 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

                              11/15

                              23 Jan 2025, 09:56

                              • Login

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