Qt Button
-
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.
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.
-
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.
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.
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.
-