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. When modal window on top of mainwidget, i can still interact with mainwidger
Forum Updated to NodeBB v4.3 + New Features

When modal window on top of mainwidget, i can still interact with mainwidger

Scheduled Pinned Locked Moved Unsolved General and Desktop
20 Posts 3 Posters 1.1k 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.
  • M Offline
    M Offline
    masa4
    wrote on last edited by
    #1

    I have some modal windows. They are inheriting QWidget and i have this in contructor:

    setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
        setWindowModality(Qt::ApplicationModal);
    

    In my gui, when i click button, modal window is appearing but i can still click to button that on mainwidget. Are there any automatic way to prevent this or i need to manually handle it?

    jsulmJ 1 Reply Last reply
    0
    • M masa4

      I have some modal windows. They are inheriting QWidget and i have this in contructor:

      setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
          setWindowModality(Qt::ApplicationModal);
      

      In my gui, when i click button, modal window is appearing but i can still click to button that on mainwidget. Are there any automatic way to prevent this or i need to manually handle it?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @masa4 Please show your code. setWindowModality(Qt::ApplicationModal) should work.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      0
      • jsulmJ jsulm

        @masa4 Please show your code. setWindowModality(Qt::ApplicationModal) should work.

        M Offline
        M Offline
        masa4
        wrote on last edited by
        #3

        @jsulm Sorry now i realized i commented out setWindowModality(Qt::ApplicationModal); Because when i have this line, i cannot interact with virtual keyboard which works like modal window as well. Actually i was expecting i should interact with my virtual keyboard because its the most top item i think.
        And by the way i have this in my virtual keyboard constructor:

        setWindowFlags(Qt::WindowStaysOnTopHint|Qt::X11BypassWindowManagerHint);
        
        jsulmJ 1 Reply Last reply
        0
        • M masa4

          @jsulm Sorry now i realized i commented out setWindowModality(Qt::ApplicationModal); Because when i have this line, i cannot interact with virtual keyboard which works like modal window as well. Actually i was expecting i should interact with my virtual keyboard because its the most top item i think.
          And by the way i have this in my virtual keyboard constructor:

          setWindowFlags(Qt::WindowStaysOnTopHint|Qt::X11BypassWindowManagerHint);
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @masa4 Does your virtual keyboard work with modal dialogs (QDialog::exec())?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          0
          • jsulmJ jsulm

            @masa4 Does your virtual keyboard work with modal dialogs (QDialog::exec())?

            M Offline
            M Offline
            masa4
            wrote on last edited by
            #5

            @jsulm I dont know, all of my ui classes(including keyboard class) inherits QWidget. And I am opening modals&keyboard with show() function.

            jsulmJ 1 Reply Last reply
            0
            • M masa4

              @jsulm I dont know, all of my ui classes(including keyboard class) inherits QWidget. And I am opening modals&keyboard with show() function.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @masa4 said in When modal window on top of mainwidget, i can still interact with mainwidger:

              I dont know

              You can try...

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              M 1 Reply Last reply
              0
              • jsulmJ jsulm

                @masa4 said in When modal window on top of mainwidget, i can still interact with mainwidger:

                I dont know

                You can try...

                M Offline
                M Offline
                masa4
                wrote on last edited by
                #7

                @jsulm You saying me, create a new ui class which inherits from QDialog and add a textbox to it, call it with exec() in a function call, , and try if keyboard will be clickable on it, am i right? Please confirm so i will try it.

                jsulmJ 1 Reply Last reply
                0
                • M masa4

                  @jsulm You saying me, create a new ui class which inherits from QDialog and add a textbox to it, call it with exec() in a function call, , and try if keyboard will be clickable on it, am i right? Please confirm so i will try it.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @masa4 There is no need to inherit enything. You can simply show https://doc.qt.io/qt-6/qinputdialog.html and check whether you can enter text using virtual keyboard...

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  M 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @masa4 There is no need to inherit enything. You can simply show https://doc.qt.io/qt-6/qinputdialog.html and check whether you can enter text using virtual keyboard...

                    M Offline
                    M Offline
                    masa4
                    wrote on last edited by
                    #9

                    @jsulm I tried but couldnt do it. I have eventfilter on my class for detecting lineedits etc focuses. So i can show my keyboard modal. I tried installing event filter to QInputDialog object and handling keyboard opening in eventfilter method but program crashes.

                    JonBJ 1 Reply Last reply
                    0
                    • M masa4

                      @jsulm I tried but couldnt do it. I have eventfilter on my class for detecting lineedits etc focuses. So i can show my keyboard modal. I tried installing event filter to QInputDialog object and handling keyboard opening in eventfilter method but program crashes.

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #10

                      @masa4
                      So you have sundry extra code of your own, which may or may not affect. Since @jsulm asked you test with just a QInputDialog exec()ed modally why don't you do so in a standalone program?

                      M 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @masa4
                        So you have sundry extra code of your own, which may or may not affect. Since @jsulm asked you test with just a QInputDialog exec()ed modally why don't you do so in a standalone program?

                        M Offline
                        M Offline
                        masa4
                        wrote on last edited by masa4
                        #11

                        @JonB But the main problem is right now; if i set Qt::ApplicationModal on my modals, it prevent interacting with mainwidget, which is good. But when i click the textedits on modal, my virtual keyboard show up as modal but i cant interact with keyboard.
                        If I dont set Qt::ApplicationModal, I can interact with keyboard but at the same time i can interact with mainwidget which is bad. My modal still beeing on top but i can click mainwidget buttons etc.
                        I tested QInputDialog, and it works well in normal situation. But I couldnt test it with keyboard since it requires additional steps/when i directly tried adding it to my event list, program crashes. I am not sure what was the problem

                        jsulmJ JonBJ 2 Replies Last reply
                        0
                        • M masa4

                          @JonB But the main problem is right now; if i set Qt::ApplicationModal on my modals, it prevent interacting with mainwidget, which is good. But when i click the textedits on modal, my virtual keyboard show up as modal but i cant interact with keyboard.
                          If I dont set Qt::ApplicationModal, I can interact with keyboard but at the same time i can interact with mainwidget which is bad. My modal still beeing on top but i can click mainwidget buttons etc.
                          I tested QInputDialog, and it works well in normal situation. But I couldnt test it with keyboard since it requires additional steps/when i directly tried adding it to my event list, program crashes. I am not sure what was the problem

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @masa4 said in When modal window on top of mainwidget, i can still interact with mainwidger:

                          my virtual keyboard show up

                          Is this a virtual keyboard implemented by you or the one provided by Qt?

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          M 1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @masa4 said in When modal window on top of mainwidget, i can still interact with mainwidger:

                            my virtual keyboard show up

                            Is this a virtual keyboard implemented by you or the one provided by Qt?

                            M Offline
                            M Offline
                            masa4
                            wrote on last edited by
                            #13

                            @jsulm by me

                            1 Reply Last reply
                            0
                            • M masa4

                              @JonB But the main problem is right now; if i set Qt::ApplicationModal on my modals, it prevent interacting with mainwidget, which is good. But when i click the textedits on modal, my virtual keyboard show up as modal but i cant interact with keyboard.
                              If I dont set Qt::ApplicationModal, I can interact with keyboard but at the same time i can interact with mainwidget which is bad. My modal still beeing on top but i can click mainwidget buttons etc.
                              I tested QInputDialog, and it works well in normal situation. But I couldnt test it with keyboard since it requires additional steps/when i directly tried adding it to my event list, program crashes. I am not sure what was the problem

                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote on last edited by
                              #14

                              @masa4 said in When modal window on top of mainwidget, i can still interact with mainwidger:

                              I tested QInputDialog, and it works well in normal situation. But I couldnt test it with keyboard since it requires additional steps/when i directly tried adding it to my event list, program crashes. I am not sure what was the problem

                              So maybe you have an issue in your code? Did you run under debugger to see where/why crash is?

                              M 1 Reply Last reply
                              0
                              • JonBJ JonB

                                @masa4 said in When modal window on top of mainwidget, i can still interact with mainwidger:

                                I tested QInputDialog, and it works well in normal situation. But I couldnt test it with keyboard since it requires additional steps/when i directly tried adding it to my event list, program crashes. I am not sure what was the problem

                                So maybe you have an issue in your code? Did you run under debugger to see where/why crash is?

                                M Offline
                                M Offline
                                masa4
                                wrote on last edited by
                                #15

                                @JonB I can try to solve the issue but what we actually try to learn? If I will be able to use my keyboard with QInputDialog, what will be the next thing?

                                jsulmJ 1 Reply Last reply
                                0
                                • M masa4

                                  @JonB I can try to solve the issue but what we actually try to learn? If I will be able to use my keyboard with QInputDialog, what will be the next thing?

                                  jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  @masa4 If it's your own virtual keyboard then you should maybe take a look at Qt virtual keyboard implementation to see how it is implemented.

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  M 1 Reply Last reply
                                  1
                                  • jsulmJ jsulm

                                    @masa4 If it's your own virtual keyboard then you should maybe take a look at Qt virtual keyboard implementation to see how it is implemented.

                                    M Offline
                                    M Offline
                                    masa4
                                    wrote on last edited by
                                    #17

                                    @jsulm Its in qml, i dont know it

                                    JonBJ 1 Reply Last reply
                                    0
                                    • M masa4

                                      @jsulm Its in qml, i dont know it

                                      JonBJ Offline
                                      JonBJ Offline
                                      JonB
                                      wrote on last edited by
                                      #18

                                      @masa4 So what sort of answer are you expecting here?

                                      M 1 Reply Last reply
                                      0
                                      • JonBJ JonB

                                        @masa4 So what sort of answer are you expecting here?

                                        M Offline
                                        M Offline
                                        masa4
                                        wrote on last edited by
                                        #19

                                        @JonB I didnt understand what you mean. I am asking how can I prevent interaction with mainwidget when modal window is open. But at the same time, I want to be able to interact with virtual keyboard which shows up when i click textedits on modal window.
                                        If I add setWindowModality(Qt::ApplicationModal); to my modal window, it prevents interaction with mainwidget buttons. But I cant interact with keyboard also.

                                        I want to interact with keyboard and prevent the interaction with mainwidget.

                                        JonBJ 1 Reply Last reply
                                        0
                                        • M masa4

                                          @JonB I didnt understand what you mean. I am asking how can I prevent interaction with mainwidget when modal window is open. But at the same time, I want to be able to interact with virtual keyboard which shows up when i click textedits on modal window.
                                          If I add setWindowModality(Qt::ApplicationModal); to my modal window, it prevents interaction with mainwidget buttons. But I cant interact with keyboard also.

                                          I want to interact with keyboard and prevent the interaction with mainwidget.

                                          JonBJ Offline
                                          JonBJ Offline
                                          JonB
                                          wrote on last edited by JonB
                                          #20

                                          @masa4
                                          What I am saying is: If the principle works OK with the Qt virtual keyboard but not with your own coded version, your own code crashes, you say earlier

                                          I can try to solve the issue but what we actually try to learn? If I will be able to use my keyboard with QInputDialog, what will be the next thing?

                                          and when @jsulm suggests you "take a look at Qt virtual keyboard implementation to see how it is implemented" you reply "Its in qml, i dont know it". If you take all this I don't know what sort of "answer" you think you are going to get from anyone here, I don't see how they can help. Anyway you can wait and see if anybody offers anything from here.

                                          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