Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Press touch screen and hot plug the touch board, qt app(push button) cannot receive mousepress event, button click not work

Press touch screen and hot plug the touch board, qt app(push button) cannot receive mousepress event, button click not work

Scheduled Pinned Locked Moved Unsolved General and Desktop
18 Posts 4 Posters 526 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.
  • Z Offline
    Z Offline
    Zonghua He
    wrote on 1 Apr 2025, 02:57 last edited by Zonghua He 4 Jan 2025, 03:14
    #1

    Before hot plug, the push button click can receive events:
    QEvent::SockAct on object: QSocketNotifier(0x5577206a00)
    QEvent::TouchBegin on object: QWidgetWindow(0x5577289e50, name = "MainWindowWindow")
    QEvent::MouseMove on object: QWidgetWindow(0x5577289e50, name = "MainWindowWindow")
    QEvent::MouseMove on object: QPushButton(0x557726fc50, name = "pushButton")
    QEvent::HoverMove on object: MainWindow(0x7fc53faeb0, name = "MainWindow")
    QEvent::MouseButtonPress on object: QWidgetWindow(0x5577289e50, name = "MainWindowWindow")
    QEvent::FocusAboutToChange on object: QRadioButton(0x55772319e0, name = "radioButton")
    QEvent::FocusOut on object: QRadioButton(0x55772319e0, name = "radioButton")
    QEvent::FocusOut on object: QWindowsStyle(0x557725dd80, name = "windows")
    QEvent::FocusIn on object: QPushButton(0x557726fc50, name = "pushButton")
    QEvent::FocusIn on object: QWindowsStyle(0x557725dd80, name = "windows")
    QEvent::MouseButtonPress on object: QPushButton(0x557726fc50, name = "pushButton")
    QEvent::UpdateRequest on object: MainWindow(0x7fc53faeb0, name = "MainWindow")
    QEvent::Paint on object: MainWindow(0x7fc53faeb0, name = "MainWindow")
    QEvent::Paint on object: QWidget(0x557725e400, name = "centralwidget")
    QEvent::Paint on object: QRadioButton(0x55772319e0, name = "radioButton")
    QEvent::Paint on object: QPushButton(0x557726fc50, name = "pushButton")
    QEvent::UpdateRequest on object: QLinuxFbScreen(0x55771da260)
    QEvent::UpdateRequest on object: MainWindow(0x7fc53faeb0, name = "MainWindow")
    QEvent::SockAct on object: QSocketNotifier(0x5577206a00)
    QEvent::TouchEnd on object: QWidgetWindow(0x5577289e50, name = "MainWindowWindow")
    QEvent::MouseButtonRelease on object: QWidgetWindow(0x5577289e50, name = "MainWindowWindow")
    QEvent::MouseButtonRelease on object: QPushButton(0x557726fc50, name = "pushButton")
    QEvent::UpdateRequest on object: MainWindow(0x7fc53faeb0, name = "MainWindow")
    QEvent::Paint on object: MainWindow(0x7fc53faeb0, name = "MainWindow")
    QEvent::Paint on object: QWidget(0x557725e400, name = "centralwidget")
    QEvent::Paint on object: QPushButton(0x557726fc50, name = "pushButton")
    QEvent::UpdateRequest on object: QLinuxFbScreen(0x55771da260)
    QEvent::UpdateRequest on object: MainWindow(0x7fc53faeb0, name = "MainWindow")

    But long press touch screen and hot plug touch board(at the same time),qt app print:
    QEvent::SockAct on object: QSocketNotifier(0x5577206a00)
    QEvent::TouchBegin on object: QWidgetWindow(0x5577289e50, name = "MainWindowWindow")
    QEvent::MouseMove on object: QWidgetWindow(0x5577289e50, name = "MainWindowWindow")
    QEvent::Leave on object: QPushButton(0x557726fc50, name = "pushButton")
    QEvent::MouseMove on object: QWidget(0x557725e400, name = "centralwidget")
    QEvent::HoverMove on object: MainWindow(0x7fc53faeb0, name = "MainWindow")
    QEvent::MouseButtonPress on object: QWidgetWindow(0x5577289e50, name = "MainWindowWindow")
    QEvent::MouseButtonPress on object: QWidget(0x557725e400, name = "centralwidget")
    QEvent::MouseButtonPress on object: MainWindow(0x7fc53faeb0, name = "MainWindow")
    Pressed position: x: 840 , y: 154
    QEvent::SockAct on object: QSocketNotifier(0x5577206a00)
    QEvent::TouchUpdate on object: QWidgetWindow(0x5577289e50, name = "MainWindowWindow")
    QEvent::MouseMove on object: QWidgetWindow(0x5577289e50, name = "MainWindowWindow")
    QEvent::MouseMove on object: QWidget(0x557725e400, name = "centralwidget")
    QEvent::MouseMove on object: MainWindow(0x7fc53faeb0, name = "MainWindow")
    QEvent::HoverMove on object: MainWindow(0x7fc53faeb0, name = "MainWindow")
    [ 5184.073284] usb 3-1: USB disconnect, device number 4
    QEvent::SockAct on object: QSocketNotifier(0x5577206a00)
    qt.qpa.input: libinput: event3 - eGalax Inc. eGalaxTouch P80H46 2177 vT1_M00 k4.10.142: device removed
    QEvent::SockAct on object: QSocketNotifier(0x5577206a00)
    QEvent::TouchCancel on object: QWidgetWindow(0x5577289e50, name = "MainWindowWindow")
    QEvent::TouchCancel on object: QWidget(0x557725e400, name = "centralwidget")
    QEvent::MouseButtonRelease on object: QWidgetWindow(0x5577289e50, name = "MainWindowWindow")
    QEvent::MouseButtonRelease on object: QWidget(0x557725e400, name = "centralwidget")
    QEvent::MouseButtonRelease on object: MainWindow(0x7fc53faeb0, name = "MainWindow")
    QEvent::SockAct on object: QSocketNotifier(0x5577206a00)

    Systerm print after hot plug:
    [ 5205.415988] usb 3-1: new full-speed USB device number 5 using ohci-platform
    [ 5205.640536] usb 3-1: New USB device found, idVendor=0eef, idProduct=c002, bcdDevice=77.00
    [ 5205.640614] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
    [ 5205.640649] usb 3-1: Product: eGalaxTouch P80H46 2177 vT1_M00 k4.10.142
    [ 5205.640679] usb 3-1: Manufacturer: eGalax Inc.
    [ 5205.656845] input: eGalax Inc. eGalaxTouch P80H46 2177 vT1_M00 k4.10.142 as /devices/platform/fd840000.usb/usb3/3-1/3-1:1.0/0003:0EEF:C002.0004/input/input13
    [ 5205.713401] hid-multitouch 0003:0EEF:C002.0004: input,hiddev96,hidraw0: USB HID v1.11 Pointer [eGalax Inc. eGalaxTouch P80H46 2177 vT1_M00 k4.10.142] on usb-fd840000.usb-1/input0
    QEvent:716455] panel-simple panel: Linked as a consumer to regulator.8
    :SockA[ct on object: QSocketNotifier(0x5577206a00)
    5205.716582] panel-simple panel: panel supply vsp not found, using dummy regulator
    [ 5205.716696] panel-simple panel: panel supply vsn not found, using dummy regulator
    [ 5205.717029] panel-simple panel: Dropping the link to regulator.8
    [ 5205.718285] panel-simple rgb-panel: Linked as a consumer to regulator.8
    [ 5205.718389] panel-simple rgb-panel: rgb-panel supply vsp not found, using dummy regulator
    [ 5205.718492] panel-simple rgb-panel: rgb-panel supply vsn not found, using dummy regulator
    [ 5205.718770] panel-simple rgb-panel: Dropping the link to regulator.8
    QEvent::SockAct on object: QSocketNotifier(0x5577206a00)
    qt.qpa.input: libinput: event3 - eGalax Inc. eGalaxTouch P80H46 2177 vT1_M00 k4.10.142: is tagged by udev as: Touchscreen
    qt.qpa.input: libinput: event3 - eGalax Inc. eGalaxTouch P80H46 2177 vT1_M00 k4.10.142: device is a touch device
    qt.qpa.input: libinput: registerDevice /dev/input/event3 - eGalax Inc. eGalaxTouch P80H46 2177 vT1_M00 k4.10.142

    Click push button, can only receive:
    QEvent::SockAct on object: QSocketNotifier(0x5577206a00)
    QEvent::TouchBegin on object: QWidgetWindow(0x5577289e50, name = "MainWindowWindow")
    QEvent::SockAct on object: QSocketNotifier(0x5577206a00)
    QEvent::TouchEnd on object: QWidgetWindow(0x5577289e50, name = "MainWindowWindow")

    Qt app print code:
    protected:
    bool eventFilter(QObject *obj, QEvent *event) override
    {
    if (1) {
    qDebug() << event->type() << " on object:" << obj;
    }

        return QObject::eventFilter(obj, event); 
    }
    

    Linux aarch64, buildroot, kernal 4.19.206. QT version: 5.15.8.
    Looking forward to your reply. Thanks for advance.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JoeCFD
      wrote on 1 Apr 2025, 11:18 last edited by
      #2

      Type the following into deepseek or grok, you may be able to find some clues.

      Before hot plug, the push button click can receive events. But long press touch screen and hot plug touch board(at the same time. qt app(push button) cannot receive mousepress event, button click not work

      Z 1 Reply Last reply 2 Apr 2025, 10:13
      0
      • J JoeCFD
        1 Apr 2025, 11:18

        Type the following into deepseek or grok, you may be able to find some clues.

        Before hot plug, the push button click can receive events. But long press touch screen and hot plug touch board(at the same time. qt app(push button) cannot receive mousepress event, button click not work

        Z Offline
        Z Offline
        Zonghua He
        wrote on 2 Apr 2025, 10:13 last edited by Zonghua He 4 Feb 2025, 10:14
        #3

        Hi JoeCFD, thanks for advice.

        AI told me to reimplement event():
        //reimplement event()
        bool MainWindow::event(QEvent *event)
        {
        QTouchEvent touchEvent = static_cast<QTouchEvent>(event);
        qDebug() << "New event:" << touchEvent->type();

        if (event->type() == QEvent::TouchBegin ||
            event->type() == QEvent::TouchUpdate ||
            event->type() == QEvent::TouchEnd) {
        
            QObject *target = childAt(touchEvent->touchPoints().first().pos().toPoint());
            qDebug() << "target: " << target;
        
            if (qobject_cast<QPushButton*>(target) ||
                    qobject_cast<QRadioButton*>(target) ||
                    qobject_cast<QComboBox*>(target) ||
                    qobject_cast<QSlider*>(target) ||
                    qobject_cast<QLineEdit*>(target) ||
                    qobject_cast<QLabel*>(target) ||
                    qobject_cast<QScrollBar*>(target)) {
                
                qDebug() << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Include.";
                return QWidget::event(event);
            }
        
            qDebug() << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Will return true.";
        
            return true;//if false,  event to QPushButton will not be deliver
        }
        
        qDebug() << "----------------------------------------------------------------- Will goto last return.";
        
        return QMainWindow::event(event); 
        

        }

        QPushButton,QRadioButton,QComboBox,QSlider,QLineEdit,QLabel,QScrollBar can work well.

        But if the clicked object is QTableWidget, it will not work.

        I have no idea how to fix it.

        J JonBJ 2 Replies Last reply 2 Apr 2025, 11:17
        0
        • Z Zonghua He
          2 Apr 2025, 10:13

          Hi JoeCFD, thanks for advice.

          AI told me to reimplement event():
          //reimplement event()
          bool MainWindow::event(QEvent *event)
          {
          QTouchEvent touchEvent = static_cast<QTouchEvent>(event);
          qDebug() << "New event:" << touchEvent->type();

          if (event->type() == QEvent::TouchBegin ||
              event->type() == QEvent::TouchUpdate ||
              event->type() == QEvent::TouchEnd) {
          
              QObject *target = childAt(touchEvent->touchPoints().first().pos().toPoint());
              qDebug() << "target: " << target;
          
              if (qobject_cast<QPushButton*>(target) ||
                      qobject_cast<QRadioButton*>(target) ||
                      qobject_cast<QComboBox*>(target) ||
                      qobject_cast<QSlider*>(target) ||
                      qobject_cast<QLineEdit*>(target) ||
                      qobject_cast<QLabel*>(target) ||
                      qobject_cast<QScrollBar*>(target)) {
                  
                  qDebug() << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Include.";
                  return QWidget::event(event);
              }
          
              qDebug() << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Will return true.";
          
              return true;//if false,  event to QPushButton will not be deliver
          }
          
          qDebug() << "----------------------------------------------------------------- Will goto last return.";
          
          return QMainWindow::event(event); 
          

          }

          QPushButton,QRadioButton,QComboBox,QSlider,QLineEdit,QLabel,QScrollBar can work well.

          But if the clicked object is QTableWidget, it will not work.

          I have no idea how to fix it.

          J Offline
          J Offline
          JoeCFD
          wrote on 2 Apr 2025, 11:17 last edited by
          #4

          @Zonghua-He Continue asking deepseek or grok.

          1 Reply Last reply
          0
          • Z Zonghua He
            2 Apr 2025, 10:13

            Hi JoeCFD, thanks for advice.

            AI told me to reimplement event():
            //reimplement event()
            bool MainWindow::event(QEvent *event)
            {
            QTouchEvent touchEvent = static_cast<QTouchEvent>(event);
            qDebug() << "New event:" << touchEvent->type();

            if (event->type() == QEvent::TouchBegin ||
                event->type() == QEvent::TouchUpdate ||
                event->type() == QEvent::TouchEnd) {
            
                QObject *target = childAt(touchEvent->touchPoints().first().pos().toPoint());
                qDebug() << "target: " << target;
            
                if (qobject_cast<QPushButton*>(target) ||
                        qobject_cast<QRadioButton*>(target) ||
                        qobject_cast<QComboBox*>(target) ||
                        qobject_cast<QSlider*>(target) ||
                        qobject_cast<QLineEdit*>(target) ||
                        qobject_cast<QLabel*>(target) ||
                        qobject_cast<QScrollBar*>(target)) {
                    
                    qDebug() << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Include.";
                    return QWidget::event(event);
                }
            
                qDebug() << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Will return true.";
            
                return true;//if false,  event to QPushButton will not be deliver
            }
            
            qDebug() << "----------------------------------------------------------------- Will goto last return.";
            
            return QMainWindow::event(event); 
            

            }

            QPushButton,QRadioButton,QComboBox,QSlider,QLineEdit,QLabel,QScrollBar can work well.

            But if the clicked object is QTableWidget, it will not work.

            I have no idea how to fix it.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on 2 Apr 2025, 13:08 last edited by
            #5

            @Zonghua-He said in Press touch screen and hot plug the touch board, qt app(push button) cannot receive mousepress event, button click not work:

            QTouchEvent touchEvent = static_cast<QTouchEvent>(event);

            One thing I don't get. How can you know that every MainWindow::event(QEvent *event) is going to be a QTouchEvent? Won't the static_cast barf if it is not?

            J Z 2 Replies Last reply 2 Apr 2025, 13:53
            1
            • JonBJ JonB
              2 Apr 2025, 13:08

              @Zonghua-He said in Press touch screen and hot plug the touch board, qt app(push button) cannot receive mousepress event, button click not work:

              QTouchEvent touchEvent = static_cast<QTouchEvent>(event);

              One thing I don't get. How can you know that every MainWindow::event(QEvent *event) is going to be a QTouchEvent? Won't the static_cast barf if it is not?

              J Offline
              J Offline
              JoeCFD
              wrote on 2 Apr 2025, 13:53 last edited by JoeCFD 4 Feb 2025, 13:53
              #6

              @JonB Good point!

              JonBJ 1 Reply Last reply 2 Apr 2025, 13:56
              0
              • J JoeCFD
                2 Apr 2025, 13:53

                @JonB Good point!

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on 2 Apr 2025, 13:56 last edited by
                #7

                @JoeCFD
                Yes but I assumed (untested) that

                QTouchEvent touchEvent = static_cast<QTouchEvent>(event);
                

                would static-cast-except if it is not a QTouchEvent? Oh, I can't remember any more, doesn't static_cast throw ab exception where dynamic_cast would (for a pointer) return nullptr? Or is static_cast just the dangerous C cast, no exception? Yeah, I'm beginning to think it's that....

                J 1 Reply Last reply 2 Apr 2025, 14:08
                0
                • JonBJ JonB
                  2 Apr 2025, 13:56

                  @JoeCFD
                  Yes but I assumed (untested) that

                  QTouchEvent touchEvent = static_cast<QTouchEvent>(event);
                  

                  would static-cast-except if it is not a QTouchEvent? Oh, I can't remember any more, doesn't static_cast throw ab exception where dynamic_cast would (for a pointer) return nullptr? Or is static_cast just the dangerous C cast, no exception? Yeah, I'm beginning to think it's that....

                  J Offline
                  J Offline
                  JoeCFD
                  wrote on 2 Apr 2025, 14:08 last edited by
                  #8

                  @JonB
                  std::static_cast:
                  No runtime checks: If you downcast a pointer to a derived class incorrectly, it leads to undefined behavior.
                  Faster: No runtime overhead.

                  std::dynamic_cast:
                  Performs a runtime check to ensure the cast is valid.
                  For pointers: nullptr if the cast fails.
                  For references: Throws std::bad_cast if the cast fails.
                  Involves runtime type information (RTTI) overhead.

                  I think std::dynamic_cast is needed.

                  JonBJ 1 Reply Last reply 2 Apr 2025, 15:39
                  0
                  • J JoeCFD
                    2 Apr 2025, 14:08

                    @JonB
                    std::static_cast:
                    No runtime checks: If you downcast a pointer to a derived class incorrectly, it leads to undefined behavior.
                    Faster: No runtime overhead.

                    std::dynamic_cast:
                    Performs a runtime check to ensure the cast is valid.
                    For pointers: nullptr if the cast fails.
                    For references: Throws std::bad_cast if the cast fails.
                    Involves runtime type information (RTTI) overhead.

                    I think std::dynamic_cast is needed.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on 2 Apr 2025, 15:39 last edited by
                    #9

                    @JoeCFD
                    OK, I think I was confusing some "static cast" in C# which did "assert" if incorrect. Got it.

                    I don't think you can use dyanmic_cast here because event is not a pointer here? dynamic_cast<QTouchEvent>(event) would not be able to return its usual nullptr if wrong type, so I don't see how you can here?

                    J 1 Reply Last reply 2 Apr 2025, 16:12
                    0
                    • JonBJ JonB
                      2 Apr 2025, 15:39

                      @JoeCFD
                      OK, I think I was confusing some "static cast" in C# which did "assert" if incorrect. Got it.

                      I don't think you can use dyanmic_cast here because event is not a pointer here? dynamic_cast<QTouchEvent>(event) would not be able to return its usual nullptr if wrong type, so I don't see how you can here?

                      J Offline
                      J Offline
                      JoeCFD
                      wrote on 2 Apr 2025, 16:12 last edited by
                      #10

                      @JonB bool MainWindow::event(QEvent *event)

                      JonBJ 1 Reply Last reply 2 Apr 2025, 16:44
                      0
                      • J JoeCFD
                        2 Apr 2025, 16:12

                        @JonB bool MainWindow::event(QEvent *event)

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on 2 Apr 2025, 16:44 last edited by JonB 4 Feb 2025, 16:45
                        #11

                        @JoeCFD
                        Here is is copied verbatim from what OP posted in https://forum.qt.io/post/823816 above:

                        bool MainWindow::event(QEvent *event)
                        {
                        QTouchEvent touchEvent = static_cast<QTouchEvent>(event);
                        

                        That is static_cast<QTouchEvent>, not static_cast<QTouchEvent *>. I think I get it. OP did not use ``` :( So the * asterisk for pointer did italic instead of visible. That's the problem with no Code tags :( I get it now, misunderstanding.

                        1 Reply Last reply
                        0
                        • JonBJ JonB
                          2 Apr 2025, 13:08

                          @Zonghua-He said in Press touch screen and hot plug the touch board, qt app(push button) cannot receive mousepress event, button click not work:

                          QTouchEvent touchEvent = static_cast<QTouchEvent>(event);

                          One thing I don't get. How can you know that every MainWindow::event(QEvent *event) is going to be a QTouchEvent? Won't the static_cast barf if it is not?

                          Z Offline
                          Z Offline
                          Zonghua He
                          wrote on 3 Apr 2025, 00:58 last edited by
                          #12

                          @JonB Hi,thanks for your idea.

                          My code is not safe. Should be:
                          bool MainWindow::event(QEvent *event)
                          {
                          if (event->type() == QEvent::TouchBegin ||
                          event->type() == QEvent::TouchUpdate ||
                          event->type() == QEvent::TouchEnd) {
                          QTouchEvent touchEvent = static_cast<QTouchEvent>(event);
                          qDebug() << "New event:" << touchEvent->type();

                              QObject *target = childAt(touchEvent->touchPoints().first().pos().toPoint());
                              qDebug() << "target: " << target;
                          
                              if (qobject_cast<QPushButton*>(target) ||
                                      qobject_cast<QRadioButton*>(target) ||
                                      qobject_cast<QComboBox*>(target) ||
                                      qobject_cast<QSlider*>(target) ||
                                      qobject_cast<QLineEdit*>(target) ||
                                      qobject_cast<QLabel*>(target) ||
                                      qobject_cast<QScrollBar*>(target)) {
                                  qDebug() << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Include.";
                                  return QMainWindow::event(event);
                              }
                          
                              qDebug() << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Will return true.";
                          
                              return true;//if false, QPushButton will not be deliver
                          }
                          
                          qDebug() << "----------------------------------------------------------------- Will goto last return.";
                          
                          return QMainWindow::event(event); 
                          

                          }

                          Do you have any idea about my problem? After hot plug touch board usb cable(finger is touching on screen at the same time), all the pushbuttons, sliders and so on, can not response. But if i hot plug the touch board usb cable without touching the touch screen, all is well. This problem always occurs on widget app. The QML app works well.

                          JonBJ 1 Reply Last reply 3 Apr 2025, 07:18
                          0
                          • K Offline
                            K Offline
                            Kevin Hoang
                            wrote on 3 Apr 2025, 03:32 last edited by
                            #13

                            Based on the log you provided, the system correctly recognizes your touchscreen after reconnecting. However, Qt has detected the device as a touchscreen through libinput (event3). This means that Qt is handling touch events instead of mouse events.

                            You might want to try adding QCoreApplication::setAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents); in your main application to see if that resolves the issue.

                            Z 1 Reply Last reply 3 Apr 2025, 07:18
                            0
                            • K Kevin Hoang
                              3 Apr 2025, 03:32

                              Based on the log you provided, the system correctly recognizes your touchscreen after reconnecting. However, Qt has detected the device as a touchscreen through libinput (event3). This means that Qt is handling touch events instead of mouse events.

                              You might want to try adding QCoreApplication::setAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents); in your main application to see if that resolves the issue.

                              Z Offline
                              Z Offline
                              Zonghua He
                              wrote on 3 Apr 2025, 07:18 last edited by
                              #14

                              @Kevin-Hoang said in Press touch screen and hot plug the touch board, qt app(push button) cannot receive mousepress event, button click not work:

                              orUnhandled

                              Hi Kevin Hoang, I did what you told me. But also not work.
                              My project is : https://github.com/hezonghua/linux_QT_touch_screen_widget_app

                              I will appreciate if you can have a look at my project. Thanks for advance.

                              1 Reply Last reply
                              0
                              • Z Zonghua He
                                3 Apr 2025, 00:58

                                @JonB Hi,thanks for your idea.

                                My code is not safe. Should be:
                                bool MainWindow::event(QEvent *event)
                                {
                                if (event->type() == QEvent::TouchBegin ||
                                event->type() == QEvent::TouchUpdate ||
                                event->type() == QEvent::TouchEnd) {
                                QTouchEvent touchEvent = static_cast<QTouchEvent>(event);
                                qDebug() << "New event:" << touchEvent->type();

                                    QObject *target = childAt(touchEvent->touchPoints().first().pos().toPoint());
                                    qDebug() << "target: " << target;
                                
                                    if (qobject_cast<QPushButton*>(target) ||
                                            qobject_cast<QRadioButton*>(target) ||
                                            qobject_cast<QComboBox*>(target) ||
                                            qobject_cast<QSlider*>(target) ||
                                            qobject_cast<QLineEdit*>(target) ||
                                            qobject_cast<QLabel*>(target) ||
                                            qobject_cast<QScrollBar*>(target)) {
                                        qDebug() << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Include.";
                                        return QMainWindow::event(event);
                                    }
                                
                                    qDebug() << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Will return true.";
                                
                                    return true;//if false, QPushButton will not be deliver
                                }
                                
                                qDebug() << "----------------------------------------------------------------- Will goto last return.";
                                
                                return QMainWindow::event(event); 
                                

                                }

                                Do you have any idea about my problem? After hot plug touch board usb cable(finger is touching on screen at the same time), all the pushbuttons, sliders and so on, can not response. But if i hot plug the touch board usb cable without touching the touch screen, all is well. This problem always occurs on widget app. The QML app works well.

                                JonBJ Offline
                                JonBJ Offline
                                JonB
                                wrote on 3 Apr 2025, 07:18 last edited by JonB 4 Mar 2025, 07:19
                                #15

                                @Zonghua-He
                                Please use the forum posts' Code tags (the </> button, or a line of ``` above and below) when posting blocks of code if you wish to avoid the incorrect code you show and my misunderstanding about what you actually have.

                                I am sorry but I do not know about your problem.

                                Z 1 Reply Last reply 3 Apr 2025, 07:55
                                0
                                • JonBJ JonB
                                  3 Apr 2025, 07:18

                                  @Zonghua-He
                                  Please use the forum posts' Code tags (the </> button, or a line of ``` above and below) when posting blocks of code if you wish to avoid the incorrect code you show and my misunderstanding about what you actually have.

                                  I am sorry but I do not know about your problem.

                                  Z Offline
                                  Z Offline
                                  Zonghua He
                                  wrote on 3 Apr 2025, 07:55 last edited by
                                  #16

                                  @JonB Thanks for your advice.

                                  1 Reply Last reply
                                  0
                                  • K Offline
                                    K Offline
                                    Kevin Hoang
                                    wrote on 3 Apr 2025, 14:20 last edited by
                                    #17

                                    I really don’t have time to help you, but I noticed that when you unplug the screen, the TouchCancel event is triggered (TouchCancel also causes MouseButtonRelease to be sent to all widgets for processing). I suspect that during the TouchCancel process, something gets stuck, preventing proper event handling when you plug the screen back in.

                                    Since the Qt version you’re using is quite old, I’m not sure if there’s any existing bug related to this.

                                    You might try calling QApplication::processEvents() in the screenAdd event and see if that helps.

                                    Also, before unplugging the screen (when everything is working fine), check whether the Input DeviceType is TouchScreen and compare if there are any differences between the initial state of the application and the state after hot-plugging.

                                    Z 1 Reply Last reply 7 Apr 2025, 02:19
                                    0
                                    • K Kevin Hoang
                                      3 Apr 2025, 14:20

                                      I really don’t have time to help you, but I noticed that when you unplug the screen, the TouchCancel event is triggered (TouchCancel also causes MouseButtonRelease to be sent to all widgets for processing). I suspect that during the TouchCancel process, something gets stuck, preventing proper event handling when you plug the screen back in.

                                      Since the Qt version you’re using is quite old, I’m not sure if there’s any existing bug related to this.

                                      You might try calling QApplication::processEvents() in the screenAdd event and see if that helps.

                                      Also, before unplugging the screen (when everything is working fine), check whether the Input DeviceType is TouchScreen and compare if there are any differences between the initial state of the application and the state after hot-plugging.

                                      Z Offline
                                      Z Offline
                                      Zonghua He
                                      wrote on 7 Apr 2025, 02:19 last edited by
                                      #18

                                      @Kevin-Hoang Hi,i tried to call QApplication::processEvents() in the screenAdd event,i found that it has no help. It still does not work. Thanks for your suggestion.

                                      1 Reply Last reply
                                      0

                                      1/18

                                      1 Apr 2025, 02:57

                                      • Login

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