Get active modal QWidget - qt

I need to know in my app if a modal window is opened when I click on a button.
So I'm searching for a method which permits to know if a modal window is opened in my application or no, and which returns the window (or NULL)
Is it possible?

See QApplication's static activeModalWidget

Related

QT click on button in widget without focus

i have an app where i have 2 widgets, one widget shows a video and the other one two buttons as transparent widget lying over the video. Means the widget with the buttons has the focus. When now somebody clicks on the video normally this should emit a signal to open a website in an external browser, but while the other widget has the focus, this signal is not emitted while the click only changes the focus to the video but is not getting the click itself.
is there a way to use the click, to change the focus and catch the click event to open my website?
Georg
I guess you can try the function: setFocusProxy()
video.setFocusProxy(button);
Maybe you can get some help.

QDialog: show() vs open()

Whats the difference between QDialog::show() and QDialog::open()?
show() will just show you the dialog without affecting the other windows in your program. open() will show() the window + prevent other windows from being accessible through setWindowModality(), i.e., it becomes a modal window.
This is useful if you want to open a file, for example, and you don't want the user to be able to do anything in the program until a file is chosen and that dialog is closed.
Quoting from Qt's manual:
A modal dialog is a dialog that blocks input to other visible windows in the same application. Dialogs that are used to request a file name from the user or that are used to set application preferences are usually modal. Dialogs can be application modal (the default) or window modal.
When an application modal dialog is opened, the user must finish interacting with the dialog and close it before they can access any other window in the application. Window modal dialogs only block access to the window associated with the dialog, allowing the user to continue to use other windows in an application.
The most common way to display a modal dialog is to call its exec() function. When the user closes the dialog, exec() will provide a useful return value. Typically, to get the dialog to close and return the appropriate value, we connect a default button, e.g. OK, to the accept() slot and a Cancel button to the reject() slot. Alternatively you can call the done() slot with Accepted or Rejected.
As it is stated in the doc, QDialog::open()
Shows the dialog as a window modal dialog, returning immediately.
whereas QDialog::show(), which is in fact QWidget::show(), will only show your dialog as a standard, non-modal widget.

How can I create a home button?

I am pretty new in the programming world. I am using Titanium, and I want a button that when I clicked on it, it will go back to the home window. Obviously, the button will be in another window.
I tried win2.open() and win2.show(), but it is not working. Any ideas?
Use titanium navigational controller
https://github.com/vuinguyen/Ti-Navigation-Controller
it would give you button for previous and home window
Jacl,
If you are in second window, just close that window on the click event of your button in the second window.
Try the following in second window
//I'm assuming that you have came from window1 to window2
//and you have a button btnHome at window 2 used to navigate back to home page
var thisWindow = Ti.UI.currentWindow;
btnHome.addEventListener('click', function(e){
thisWindow.close(); //Will close the current window and display the previous one
});
There is a similar question which is used to navigate between windows. Go through Titanium Mobile: cant navigate between pages.
You can use the following links also for references
http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.Window-property-url
http://docs.appcelerator.com/titanium/latest/#!/api/Global-method-require

Unable to switch to Alert without closing window popup in webdriver

Scenario:
Enter a keyword (Position) in a textbox
press Tab or click on the next element
A window popup appears
a list of position matching the criteria will be listed
click the required record
Popup window closes automatically
Alert will be displayed
have click on ok button of alert.
switch to main window and check the position details
Question :- i found many solutions in the site but all are about performing actions on window popup and close the popup then switch to alert or main browser
but my application closes the popup window automatically after selection,hence i cannot use the driver.close() or driver.switchto.defaultContent().
If i dont close the driver (for popup) im not able to identify the next alert displayed after popup.
if i switch directly to mainwindhandle, the alert dismiss is happening instead of accept.
Please anyone who know how to switch from window popup to alert without popup close help is needed...
Thanks ....
If alert dismiss is happening when you are trying to accept it, why don't you use alert.dismiss(), it will probably accept the alert in your context.
When you switch to the popup window, the driver focus is on the popup window. What you might want to do is, just after clicking the required record, switch to the main window then accept the alert.
This must be helpful for you . From your questions, Even after your pop up closes automatically you must be able to access your parent window element by switching back to it. There is no need of driver.close() all the time. Here is the code,
// do something with the pop up and it closes automatically here.
driver.switchTo().defaultContent();
driver.switchTo().frame("your parent window mainframe"));
// try to access your parent window element here

Close all popup dialogs when main window closed in ASP.NET

In my web application a lot of popups opened from the parent window using 'window.open'. So I want to close all those popups when my application's main window is closed. How can I do that?
It's a bit problematic to know that the user closes the window but assuming you do achieve that (by a close button or subscribing to the beforeUnload event) you can close the opened windows by following the next bullets:
When opening a window, save its
object which is returned from the
window.open method (preferably to an
array so you have all objects in a
central place).
When you find out the main window is
closing, execute the close method
on the saved window objects.
Another possibility:
Use timer on the opened windows to
check if opener is defined (you
can try to use typeof on a method in
the opener page).
When you find out the opener doesn't
exist, close the window.
There's no callback that will notify you that the user closed his browser.
its not possible! You cannot catch browser close event.
You can use model popups to be sure user closed popups before closing the main window.

Resources