Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. QtonPi
  4. Use a touchscreen with Raspberrypi and QML

Use a touchscreen with Raspberrypi and QML

Scheduled Pinned Locked Moved Solved QtonPi
2 Posts 1 Posters 2.3k 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.
  • D Offline
    D Offline
    davidino
    wrote on last edited by davidino
    #1

    Goodmorning,
    I write you since I'm trying to use a tft display waveshare 3.5a together with a RaspberryPi0 and use its touchscreen.

    • The program controls the HDMI screen and then it's copy to the tft display with https://github.com/tasanakorn/rpi-fbcp.

    • I developed an application with QML and C++ languages, the MouseArea object works with mouse but it doesn't with touchscreen. Trying to substitute it with MultiPointTouchArea, it's the same.

    • The touch screen works correctly since I could calibrate it with the program ts_calibrate. If I use the "cat /dev/input/touchscreen0" on the command prompt, clicking on the touchscreen I got response.

    • The raspberry pi image was generated with Boot2Qt and the Qt version is 5.12.0.

    • Before launching the application, I launch the following bash script to configure some variables. I tried several configurations commenting/uncommenting some of them but unsuccessfully.

    #!/bin/sh
    
    export PATH=${PATH}:/usr/bin/qt5
    
    # the other option is linuxfb if just using qt widgets
    export QT_QPA_PLATFORM=eglfs
    
    # physical width and height units are mm
    
    # for the official Pi 7" touchscreen
    #export QT_QPA_EGLFS_PHYSICAL_WIDTH=155
    #export QT_QPA_EGLFS_PHYSICAL_HEIGHT=86
    
    # for the pitft35r 480x320 touchscreen
    #export QT_QPA_EGLFS_WIDTH=480
    #export QT_QPA_EGLFS_HEIGHT=320
    #export QT_QPA_EGLFS_PHYSICAL_WIDTH=85
    #export QT_QPA_EGLFS_PHYSICAL_HEIGHT=50
    # set a rotate value appropriate with the one used in the overlay 
    #export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/touchscreen0:rotate=90
    
    # for the pitft28r 320x240 touchscreen
    #export QT_QPA_EGLFS_WIDTH=320
    #export QT_QPA_EGLFS_HEIGHT=240
    #export QT_QPA_EGLFS_PHYSICAL_WIDTH=78
    #export QT_QPA_EGLFS_PHYSICAL_HEIGHT=50
    # set a rotate value appropriate with the one used in the overlay 
    #export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/touchscreen0:rotate=90
    
    #export TSLIB_CONFFILE=/etc/ts.conf
    #export TSLIB_CALIBFILE=/etc/pointercal
    #export TSLIB_CONSOLEDEVICE=none
    export TSLIB_FBDEVICE=/dev/fb1
    export TSLIB_TSDEVICE=/dev/input/touchscreen0
    #export TSLIB_PLUGINDIR=/usr/lib/ts
    #export QWS_MOUSE_PROTO='Tslib:/dev/input/event0'
    
    #export QT_QPA_EGLFS_DISABLE_INPUT=1
    export QT_QPA_FB_TSLIB=1
    #export QT_QPA_EGLFS_HIDECURSOR=1
    #export QT_QPA_EVDEV_MOUSE_PARAMETERS=abs
    export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/touchscreen0:rotate=90
    
    if [ -z "${XDG_RUNTIME_DIR}" ]; then
        export XDG_RUNTIME_DIR=/tmp/user/${UID}
    
        if [ ! -d ${XDG_RUNTIME_DIR} ]; then
            mkdir -p ${XDG_RUNTIME_DIR}
        fi
    fi
    

    Apparently there is a problem for the QML to intercept the touchscreen events.
    Can you advise me?

    Thank you in advanced.
    Davidino

    1 Reply Last reply
    0
    • D Offline
      D Offline
      davidino
      wrote on last edited by
      #2

      Solution here:
      https://forum.qt.io/topic/115562/how-to-make-widgets-react-to-touches-instead-of-mouse-clicks/7

      Thank you.

      1 Reply Last reply
      1

      • Login

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