QDialog should only be visible in one document

Need help, or want to share a macro? Post here!
Posts: 68
Joined: Wed Oct 17, 2018 9:00 am

QDialog should only be visible in one document

Postby Chri1 » Sun May 03, 2020 11:40 am

I have a non-modal dialog, made with QT.

When I run it, it appears as I wanted it, but when I switch to another document, the dialog is still visible (also if I switch to the macro-Editor).
It should only be visible in the document, where I called it.

Code: Select all

import PySide
from PySide import QtGui ,QtCore
from PySide.QtGui import *
from PySide.QtCore import *
pfad = "C:/...... .ui"

d = QtGui.QWidget()  # or d = QtGui.QDialog(), I see no difference
mw = FreeCADGui.getMainWindow()
mdi = mw.findChild( QtGui.QMdiArea ) 
swa = mdi.activeSubWindow()
What to do?
Posts: 5485
Joined: Fri Nov 09, 2018 5:38 pm

Re: QDialog should only be visible in one document

Postby openBrain » Sun May 03, 2020 12:21 pm

You can try to declare as its parent :

Code: Select all

Also maybe try to declare it as a "Tool" dialog.

If this doesn't work, you have to try to connect to signal (maybe 'windowStateChanged' of the activeSubWindow()) or install an event filter on the activeSubWindow().widget() to catch the ShowEvent & HideEvent. ;)