Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Question about modal file open dialog box
dolevo last edited by
I use QWebView in my application and at a certain point I open a File Digalog Box to let user choose a file from his computer. However, this box comes modal and I can't, for example, move the mouse cursor to a certain location. What happens is that, the mouse cursor moves after the user selects the file, after the dialog box is closed. Could anyone tell me how I make it non-modal? How I can move the mouse cursor to a specific target after I open a Dialog Box?
Note: Dialog Box is opened after clicking a file upload button on the html page loaded into QWebView.
Well any dialog has a setModal(true/false) method but since it's provided by the webview I don't think you get any access to it (I might be wrong).
You can move cursor with "QCursor::setPos()":http://qt-project.org/doc/qt-5/qcursor.html#setPos
Out of curiosity - what's wrong with cursor moving after the dialog? Isn't it considered annoying if an app moves your cursor around? I could imagine a multi-screen situation when I open a dialog, move it to the other screen, select something and bam! my cursor is gone and I need to furiously move my mouse to spot the cursor and figure out it moved back to the other screen. Man I hate that :P
dolevo last edited by
You are right that it is annoying moving mouse cursor is a bit annoying but I am actually trying to simulate user clicks to upload preselected file from the computer. As an example, to upload an image to a very well known image hosting services, you have to click on a upload button and select the image file in your computer and it uploads it for you. However, I am trying to do the same thing for a folder where I have all my images. Instead of clicking one by one, I want to simulate this action for all images in the folder.
Oh, ok. In that case I think you're going at it the wrong way. What if the "very well known image hosting service" changes layout (not uncommon) and moves the button just enough that you're now clicking on something else like a popup ad?
Image hosts usually have an API that you can use to upload stuff. I would go that way instead of hacking around and hijacking user property (the cursor) ;)