I am noticing that my MousePressEvent functions are not working as intended when I use the touchscreen functionality of my computer.
The buttons on my GUI are intended to change color on a press event and on release, return to original color and perform a function.
There are four scenarios:
Mouse press on the QLabel button and instantly release - Works as intended
Mouse press on the QLabel button, drag mouse, and release (slight delay in hold) - Works as intended
Finger press on the QLabel and instantly release (normal tap) - does not change image color but performs the function in MouseReleaseEvent.
Finger press on the QLabel, drag finger, and release (slight delay in hold) - Works as intended
Even a long hold in the same position on scenario 3 doesn't cause the image to change color, I have to drag my finger for a 1/4 second to make it work.
This is my code:
self.saveImageBTN = QtWidgets.QLabel(self.cameraViewer)
self.saveImageBTN.setPixmap(QPixmap("Graphics/saveImageButton.png").scaled(100,100))
self.saveImageBTN.setGeometry(QtCore.QRect(110, 610, 100, 100))
self.saveImageBTN.setObjectName("saveImageBTN")
self.saveImageBTN.mousePressEvent = self.saveImageButtonPress
self.saveImageBTN.mouseReleaseEvent = self.saveImageButtonRelease
def saveImageButtonPress(self, event):
self.saveImageBTN.setPixmap(QPixmap("Graphics/saveImageButtonPressed.png").scaled(100,100))
def saveImageButtonRelease(self, event):
self.saveImageBTN.setPixmap(QPixmap("Graphics/saveImageButton.png").scaled(100,100))
self.ImagePlayer.saveImage()
I have tried to add delays around the code in my saveImageButtonPress function to account for touchscreen latency but it doesn't seem to help.
Any help appreciated.
Related
(On mozilla firefox), if you click on the scroll bar on the right of the screen and hold it down, when you move up and down whilst holding the mouse down, it doesn't matter whether your mouse is on the program itself or not. You can click and hold on it and move your mouse to another display entirely and the program will still scroll up and down a webpage.
I am trying to do the same thing in SDL2 with a program, but when I made a scroll bar, as soon as I mouse off the application it stops and freezes in the Y location that it was before I moused off the display.
I am trying to use mouse cursor in Qt5 application.
When I run ./Qt5_CinematicExperience :
Failed to move cursor on screen HDMI1: -14
Could not set cursor on screen HDMI1: -6
There is no mouse cursor displayed on the screen.
Same results with another Qt5 application.
The click event seems to be working.
I am using Yocto rocko on kernel 4.14.24.
Do you think Qt5 needs a specific library to use mouse?
My mouse is present as input device in /dev/input/.
A cat command on /dev/input/event1 displays a lot of characters when I move the mouse.
Check if you have this line in your QT_QPA_EGLFS_KMS_CONFIG:
"hwcursor" : false
The problem isn't with the input device at all: it clearly works. It has to do with the cursor - the thing that you see on-screen that represents the position of the mouse. I'd guess that Qt tries to be clever about how it displays the cursor - as Groleo said, very likely the hardware or the drivers doen't support a hardware-accelerated mouse cursor.
You could easily see that the mouse works by implementing the mouse cursor yourself :)
I'm in a ArchLinux with OpenBox and I want to hide the cursor on fullscreen inside a Qt 4.8 application. I am aware about some other question about it but no one works every time: sometimes the cursor is hiding, sometimes not. I didn't managed to understand exactly when the problem occurs but I think that maybe is it related with the screensaver because if I test my application just after the computer is restarted the mouse cursor is no visible (and it is what I want) but if I test this feature during the day the mouse cursor is still visible in fullscreen.
This is my code:
void MainWindow::toggleFullScreen()
{
if(!this->isFullScreen())
{
this->showFullScreen();
#ifdef Q_WS_QWS
QWSServer::setCursorVisible( false );
#endif
}
else
{
this->showNormal();
}
}
I want to hide the cursor on fullscreen ...
You could set the cursor to be the blank cursor:
widget->setCursor(Qt::BlankCursor);
Also, as the docs state:
Some underlying window implementations will reset the cursor if it leaves a widget even if the mouse is grabbed. If you want to have a cursor set for all widgets, even when outside the window, consider QApplication::setOverrideCursor().
So you can call:
QApplication::setOverrideCursor(Qt::BlankCursor);
There is a program named unclutter that hides the mouse pointer. Here's an ArchLinux package:
https://www.archlinux.org/packages/community/i686/unclutter/
I currently use it on an embedded system for hiding the mouse cursor on a touchscreen.
Title says it all! My program should run in background and sometimes move to a coordinate and do a mousepress. I can move the mouse, but I can't make it click. Is it possible somehow?
I have written code for my graph and it works fine, but when I need to resize it, problems start.
Resize event doesn't fit my QGraphicScene to QGraphicsView, but same code in paint event works fine.
I can't use paint event, 'cause it makes recursive painting in symbian(It works fine in desktop).
Resize event works fine if I resize window after first run, but I wan't to fit scene in my view from first run to end of program.
Here is pics of resizeEvent:
and paintEvent:
Both event's have same code inside.
Thanks in advance.