[PySide] determine if pyside is run as standalone or inside of host app

Sean Fisk sean at seanfisk.com
Sun Jul 13 18:17:21 CEST 2014

Hi Frank,

I would go for a different architecture if possible. Have you considered
giving TestWidget a signal which gets connected to app.quit() in the
standalone application? In the host application, just don't connect it to
anything. You could name the signal 'quit_requested' or something like
that, but adapt it to your scenario. I'm not sure if this is possible in
your situation; just a suggestion.

- Sean

Sean Fisk

On Sun, Jul 13, 2014 at 9:19 AM, Frank Rueter | OHUfx <frank at ohufx.com>

> Hi,
> I have a QWidget that uses
> self.setWindowFlags(QtCore.Qt.Popup)
> This causes the widget to not quit the QApplication when it closes even
> though it's the main widget.
> I can put something like QtGui.QApplication.instance().quit() into the
> appropriate event to ensure the application closes properly, but most of
> the time this widget will be run from inside a host application, not as
> a standalone app, so closing the application instance would have fatal
> consequences for the user.
> What would be the best way to determine whether the widget is run as a
> standalone, and I can quite the application safely, or if it's run from
> inside a host app?
> In my current scenario I could check
> QtGui.QApplication.applicationFilePath() for the host applications that
> this is mostly going to be run from, but if somebody else imports my
> code into an app I didn't cater for, my QWidget will quit that when the
> widget closes, until I include the particular host in my code logic.
> Here is a simple example that always manually quits the application
> (when I need ti be clever and not quit if it's run from inside a host):
> http://pastebin.com/48y7nqc2
> What's the best way to go about this?
> Cheers,
> frank
> _______________________________________________
> PySide mailing list
> PySide at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/pyside
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20140713/51d00afd/attachment.html>

More information about the PySide mailing list