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. popup modal dialog does not have focus on touch screen
Forum Updated to NodeBB v4.3 + New Features

popup modal dialog does not have focus on touch screen

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 7 Posters 3.3k Views 2 Watching
  • 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.
  • jsulmJ jsulm

    @JoeCFD Did you read what @JonB wrote?
    Calling raise/activate/focus in constructor isn't a good idea.

    JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by JoeCFD
    #7

    @jsulm I did. I moved them out. They were not there before. I still think it is a focus problem since all buttons work fine when pressed on the main window.

    1 Reply Last reply
    0
    • Pl45m4P Pl45m4

      So you have to click once inside your non-focused dialog with your mouse (focus + button click at once) but twice (first tap focus, second tap to press button) with a finger on your touchscreen?

      A tap on screen will trigger QTouchEvents and not QMouseEvents directly. There could be something wrong...

      Have you tried to debug / print the QEvent, which you get from one single tap on your dialog?

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #8

      @Pl45m4 said in popup modal dialog does not have focus on touch screen:

      A tap on screen will trigger QTouchEvents and not QMouseEvents directly. There could be something wrong...

      Have you checked the result of the QTouchEvent?
      If Raise , Focus and so on are connected to the QMouseEvent and not to the QTouchEvent directly, maybe you have to emit or trigger some signals / events to have the same effect on finger tap as on mouse click.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      JoeCFDJ 1 Reply Last reply
      0
      • Pl45m4P Pl45m4

        @Pl45m4 said in popup modal dialog does not have focus on touch screen:

        A tap on screen will trigger QTouchEvents and not QMouseEvents directly. There could be something wrong...

        Have you checked the result of the QTouchEvent?
        If Raise , Focus and so on are connected to the QMouseEvent and not to the QTouchEvent directly, maybe you have to emit or trigger some signals / events to have the same effect on finger tap as on mouse click.

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #9

        In order to receive QTouchEvent, the button widget has to have attribute Qt::WA_AcceptTouchEvents. It is set and QTouchEvent can be received. Event filter is added to the buttons and dialog for QTouchEvent. Now one press on the touch screen activates one button. It works now. Thanks a lot for your tip.
        However, the touch event can be received only for the dialog, but the buttons when the exact code is used to pop up the dialog from another main window.
        I still think the focus is the root cause. The pop-up dialog simply can not get the focus.

        1 Reply Last reply
        0
        • Pl45m4P Pl45m4

          So you have to click once inside your non-focused dialog with your mouse (focus + button click at once) but twice (first tap focus, second tap to press button) with a finger on your touchscreen?

          A tap on screen will trigger QTouchEvents and not QMouseEvents directly. There could be something wrong...

          Have you tried to debug / print the QEvent, which you get from one single tap on your dialog?

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #10

          @Pl45m4 A tap on screen does trigger QEvent::MouseButtonPress. That is why all other buttons on the main window work fine.

          1 Reply Last reply
          0
          • JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by
            #11

            Still have not figured out how to let the pop-up dialog get focus. Any help?

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #12

              Hi
              I would try without the line
              setWindowFlags((Qt::WindowFlags)(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint));
              and see if still the same.

              Also, i would qDebug()
              QWidget *QApplication::focusWidget()
              to see who got the focus then.

              What platform is this on ?

              JoeCFDJ 1 Reply Last reply
              0
              • mrjjM mrjj

                Hi
                I would try without the line
                setWindowFlags((Qt::WindowFlags)(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint));
                and see if still the same.

                Also, i would qDebug()
                QWidget *QApplication::focusWidget()
                to see who got the focus then.

                What platform is this on ?

                JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by
                #13

                @mrjj It is on Ubuntu. The flag settings are as follows:
                setWindowFlags((Qt::WindowFlags)(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint));
                I checked the focus widget which is on a button inside the main widget. The problem is why the pop-up dialog or its children can not get focus?

                1 Reply Last reply
                0
                • X Offline
                  X Offline
                  xala_qt
                  wrote on last edited by
                  #14

                  Did you solve this problem, @JoeCFD ? I am having the same problem and starting to be a bit desperated. Thanks to all in advance.

                  1 Reply Last reply
                  0
                  • JoeCFDJ Offline
                    JoeCFDJ Offline
                    JoeCFD
                    wrote on last edited by
                    #15

                    Add event filter and handle press event. Then check event position and you know which button is clicked.

                    S 1 Reply Last reply
                    0
                    • JoeCFDJ JoeCFD

                      Add event filter and handle press event. Then check event position and you know which button is clicked.

                      S Offline
                      S Offline
                      swansorter
                      wrote on last edited by swansorter
                      #16

                      @JoeCFD Not yet.Did you solve it?

                      1 Reply Last reply
                      0
                      • X Offline
                        X Offline
                        xala_qt
                        wrote on last edited by xala_qt
                        #17

                        @JoeCFD , @swansorter, I finally figured out what whas happening in my case. Since my touch screen is a capacitive one, I had to create my qdialog on mousereleaseevent, instead of on mousepressevent.

                        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