PDA

View Full Version : Trying to get simple button-down working?



tpillera
26th July 2018, 14:38
Hello,

I have about 2-weeks of Qt experience so am very much a beginner.

Here is my setup:
Qt 5.11 running on Ubuntu 16.04
Beaglebone Black target SBC running latest Debian build
Adafruit 800x480 HDMI/USB touchscreen display

Here is where I am at:
Built a basic widget program with buttons and text-box
Downloaded to SBC
Able to display and drag cursor to button area and click (display is running in “digitizer”mode as was unable to get it to work in mouse mode)
Signals and slots work as on-click produces output in text-box as desired

Here is the seemingly simple thing I want to accomplish:
Instead of dragging the mouse and clicking the button I want to press the touch-screen in the button area and have it activate (button-down).

I am on a very tight time-frame to get this to work. I started looking at the button class, mouse class, and touch-screen class but not sure which if any of these are going to accomplish this. Any assistance or examples would be appreciated, thanks!

d_stranz
26th July 2018, 16:43
Maybe this will help: From the QTouchEvent documentation:


To receive touch events, widgets have to have the Qt::WA_AcceptTouchEvents attribute set

Call QWidget::setAttribute() through your QPushButton pointer:



myButton->setAttribute( Qt::WA_AcceptTouchEvents );

tpillera
28th July 2018, 18:31
Thanks but that doesn't exactly fix the problem. I really don't want a mouse or mouse pointer at all, just the buttons and button presses. When the mouse is not focused on the button pressing the button (or anywhere on the touchpad) is intercepted as a mouse click and not handled by the pushbutton. Should I be writing this as a Qt Quick project or am I starting with the wrong base class/

d_stranz
29th July 2018, 17:56
If you read further in the Qt::WidgetAttribute documentation, you will find this: Qt::WA_TransparentForMouseEvents. If that still doesn't do what you want, you may have to install an event filter on your buttons and eat mouse events. QObject::installEventFilter().

tpillera
1st August 2018, 15:25
Still no luck!

There is a project https://startingelectronics.org/projects/raspberry-PI-projects/kiosk-Qt/ that is close to what I am trying to do in terms of the buttons. I actually downloaded this ant got it to build for the Beaglebone Black but when I run it there is no button press UNLESS the mouse is positioned over the button. I think the problem is that I am not using any kind of server ea. X11, I am writing directly to the linuxfb (./program -platform linuxfb)? I am using a HDMI display and USB touch-screen.