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. Modal Dialogs break Virtual Keyboard
Forum Updated to NodeBB v4.3 + New Features

Modal Dialogs break Virtual Keyboard

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.8k 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.
  • D Offline
    D Offline
    DalePennington
    wrote on last edited by
    #1

    We have a virtual keyboard that has worked fine for all our other uses.

    But when it is being used for a widget in a modal dialog box, the keyboard window displays, but no mouse events are delivered to it.

    I have a test app with both modal and modeless dialogs, and shows the virtual keyboard behaving correctly with the modeless, but not with the modal.

    Is there a magic setting I am missing to get the virtual keyboard to work with modal dialogs ?

    Thanks,
    Dale Pennington

    Pl45m4P 1 Reply Last reply
    1
    • D DalePennington

      We have a virtual keyboard that has worked fine for all our other uses.

      But when it is being used for a widget in a modal dialog box, the keyboard window displays, but no mouse events are delivered to it.

      I have a test app with both modal and modeless dialogs, and shows the virtual keyboard behaving correctly with the modeless, but not with the modal.

      Is there a magic setting I am missing to get the virtual keyboard to work with modal dialogs ?

      Thanks,
      Dale Pennington

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

      @DalePennington

      Looks like

      • https://bugreports.qt.io/browse/QTBUG-56918

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

      ~E. W. Dijkstra

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DalePennington
        wrote on last edited by DalePennington
        #3

        Yep, that looks like it to a "T".

        Looks like they did some sort of hack to their QtVirtualKeyboard to make it work.

        Now if I can somehow figure out how to apply that to my much simpler virtual keyboard.

        Dale

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DalePennington
          wrote on last edited by
          #4

          OK , looking at the code changes it kinda makes sense. Something about making the Input Panel window the sibling to the "overlay", by using some code that looks like :

          QQuickItem *pInputPanel;  // The virtual keyboard panel
          QQuickItem *pInputItem;   // The Focus Object
          
          pInputPanel->setParentItem(pInputItem->window()->contentItem());
          

          The problem it that it is QML specific, and our input panel is widget based. Which leads to the question, if I have :

          QDialog *pInputPanel;
          QObject *pInputItem;
          

          What code do I use to get the equivalent effect. I have not used QML, but looking at the reference, setParentItem is not the same as setParent, and I do not have a good idea what the equivalent to QQuickWindow::contextItem would be.

          Thanks,
          Dale

          D 1 Reply Last reply
          0
          • D DalePennington

            OK , looking at the code changes it kinda makes sense. Something about making the Input Panel window the sibling to the "overlay", by using some code that looks like :

            QQuickItem *pInputPanel;  // The virtual keyboard panel
            QQuickItem *pInputItem;   // The Focus Object
            
            pInputPanel->setParentItem(pInputItem->window()->contentItem());
            

            The problem it that it is QML specific, and our input panel is widget based. Which leads to the question, if I have :

            QDialog *pInputPanel;
            QObject *pInputItem;
            

            What code do I use to get the equivalent effect. I have not used QML, but looking at the reference, setParentItem is not the same as setParent, and I do not have a good idea what the equivalent to QQuickWindow::contextItem would be.

            Thanks,
            Dale

            D Offline
            D Offline
            DalePennington
            wrote on last edited by
            #5

            After further review of the "Fix" for the QtVirtualKeyboard. As written it appears it would only work on QML based applications, as they dynamic cast the focus object to the QQuickItem. In a Widget based application, this would result in a null pointer.

            So the question comes back to wether there is a Widget based equivalent fix.

            D 1 Reply Last reply
            0
            • D DalePennington

              After further review of the "Fix" for the QtVirtualKeyboard. As written it appears it would only work on QML based applications, as they dynamic cast the focus object to the QQuickItem. In a Widget based application, this would result in a null pointer.

              So the question comes back to wether there is a Widget based equivalent fix.

              D Offline
              D Offline
              DalePennington
              wrote on last edited by
              #6

              After a lot more testing, and following some of the referenced bug reports, I found a workaround mentioned that works. The QWidget windowModality property controls what windows are affected when the specified widget is a modal window. By default it is ApplicationModal (all windows are affected). But if it is changed to WindowModal, then it only affects it parent, grandparent, and their sibling windows. So windows that do not have a parent (like the virtual keyboard input panel), or are far enough away in the window tree are will be usable.

              Note that this means your dialog will need to have a proper parent (in the app I was working on, they were unparented originally), and if your application was complicated enough you might find windows you did not expect still being manipulable. But this should solve things in most cases.

              1 Reply Last reply
              4
              • KH-219DesignK KH-219Design referenced this topic on
              • L Offline
                L Offline
                Lampkeeper
                wrote on last edited by
                #7

                Final Problem Solution:

                https://blog.csdn.net/qq_32854345/article/details/128022276

                1 Reply Last reply
                0

                • Login

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