Qt Button
-
wrote on 22 Jan 2025, 08:21 last edited by
-
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?
-
@Rkutun Is this a touch screen issue? I guess your calculation to find the region from touch position is fast enough.
wrote on 23 Jan 2025, 05:19 last edited by@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.
-
@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.
@Rkutun You will have to provide more information about your implementation. Optimally show the code.
-
wrote on 23 Jan 2025, 06:28 last edited by
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(); -
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();@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. -
wrote on 23 Jan 2025, 06:40 last edited by
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?
-
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?
@Rkutun "It is not clear where you're executing this code." - you did not answer this...
-
wrote on 23 Jan 2025, 06:51 last edited by
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.
-
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.
-
wrote on 23 Jan 2025, 09:56 last edited by
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.
-
wrote on 23 Jan 2025, 14:04 last edited by
Help please!!!
-
@Rkutun Try to profile your app on the device to see where it spends most time when the button lags.
-
wrote on 24 Jan 2025, 12:00 last edited by
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.
-
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.
1/15