When modal window on top of mainwidget, i can still interact with mainwidger
-
I have some modal windows. They are inheriting
QWidgetand 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?
-
I have some modal windows. They are inheriting
QWidgetand 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?
-
@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); -
@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); -
@jsulm I dont know, all of my ui classes(including keyboard class) inherits QWidget. And I am opening modals&keyboard with show() function.
@masa4 said in When modal window on top of mainwidget, i can still interact with mainwidger:
I dont know
You can try...
-
@masa4 said in When modal window on top of mainwidget, i can still interact with mainwidger:
I dont know
You can try...
-
@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.
@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...
-
@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...
@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.
-
@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.
-
@JonB But the main problem is right now; if i set
Qt::ApplicationModalon 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 setQt::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 testedQInputDialog, 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 -
@JonB But the main problem is right now; if i set
Qt::ApplicationModalon 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 setQt::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 testedQInputDialog, 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@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?
-
@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?
-
@JonB But the main problem is right now; if i set
Qt::ApplicationModalon 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 setQt::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 testedQInputDialog, 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@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?
-
@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?
-
@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?
-
@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.
-
@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 addsetWindowModality(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.
-
@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 addsetWindowModality(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.
@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 earlierI 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.