It looks like you're new here. If you want to get involved, click one of these buttons!
Hi,
I want to execute a dialog from a .ui file, that has a button that launches a BrowserDialog. So I followed your example here
I just replaced the code inside button.clicked block, so that it launches a BrowserDialog instead of moving the slider. However, on Win10 (and possibly other OSs) it does launch the browser but you can't click on it to read it or to close it -- because the primary dialog takes precedence. How to suppress this behavior so that you can interact with the BrowserDialog?
module QtCreatorDialog
include RBA
# Load the UI file
# We use the sample file provided as resource
ui_file = QFile.new(":/macro-templates/qt_designer.ui")
ui_file.open(QIODevice::ReadOnly)
dialog = QFormBuilder::new.load(ui_file, Application::instance.main_window)
ui_file.close
def dialog.setup
button.clicked {
RBA::BrowserDialog.new("Some text").exec
}
end
dialog.setup
dialog.exec
end
Comments
I should mention what I've tried. Several C++ solutions to this problem I've found online involve using .activateWindow, .raise, and/or .setFocus. I try all three inside button.clicked, but it doesn't work
Also, if not possible to have a 'child' RBA::BrowserDialog, then just getting it working for any 'child' QDialog is fine, but I have been unable to.
Hi David,
The problem is easy to solve if you give the BrowserDialog a parent which is the dialog you call it from. Then there is a strict hierarchy of widgets and the priority is defined properly.
Unfortunately there is no parent argument to the constructor of BrowserDialog and setting the parent after the constructor is called does not have the desired effect (don't ask my why).
But the BrowserDialog's capabilities are not quite pronounced, so you may be able to emulate the functionality. Like this:
Best regards,
Matthias
Thanks Matthias, as always it works like a charm.
(Perhaps you saw the next question coming...): Why need to release resources immediately? Because I have never used the .destroy method for anything else, so would like to know when it is appropriate or needed.
You guessed right, I saw it upcoming :-)
I got used to using
destroy
a little myself. Not out of necessity, but mainly because if there are issues connected to that, those will pop up then rather than being triggered at some arbitrary point in time later on when the garbage collector chooses to destroy the object.Please keep in mind that destruction of the dialog object will destroy the child widgets too and we learned that there are some pitfalls related to that (although I am trying to improve robustness against side effects of the destructor). Since garbage collector related issues tend to be very difficult to reproduce and even more difficult to trace back, I think that making things a little more predicable is a good habit - but not a necessity.
Best regards,
Matthias