On Friday 01 October 2010 14:21:38 Stefan Larsson wrote:
> Ah, that looks simple enough, thank you.
> 
> This make me think about two new issues which I need to understand before
> making a first experiment:
> 
> 1. Can PySide use the QApplication object from the C++ application? I
> assume that the object must be registered with PySide in some way such
> that PySide understands that a QApplication object is available?

Yes, it *will* use the current QApplication.
 
> I assume that I should expect problems when using a QWidget from another
> QApplication (with a different QPaintDevice) in different QApplication.
> The reason I ask is that when creating a QWidget without a QApplication the
> error message "QWidget: Must construct a QApplication before a
> QPaintDevice" is obtained...

Qt was designed to have just one QApplication instance per process, so the 
Python code will use your QApplication automatically without changes in your 
code, our cleanup code uses "QApplication::instance()" so there'll be no 
problems... only the qApp "macro" will not be available to your python code.

> 2. Have you experienced any best practices when it comes to destroying
> widgets which are embedded in this way?  If a C++ parent widget with a
> PySide child is destroyed in the C++ application, would the PySide widget
> be destroyed in a proper way or should I pay special attention to such
> embedded PySide widgets?

Yes, it should be deleted automagically. We suffer from the same problem in 
pure python programs when Qt deletes some object. If the PySide widget was 
explicitly created in Python will be even better, because the underlying C++ 
object will have a destructor to tell PySide that the C++ object was deleted.

Regards

> 2010/10/1 Renato Araujo Oliveira Filho <[email protected]>
> 
> > Hi Stefan,
> > 
> > you can use the header generated by pyside for QtGui module found in
> > "$PREFIX/include/PySide/QtGui/pyside_qtgui_python.h", then use these
> > functions:
> > 
> > Retrieve the C++ pointer from a Python object:
> >      cppObj* = Shiboken::Converter< [c++ type] >::toCpp(PythonObject*)
> > 
> > Retrieve the Python object from a  c++ object:
> >      PyObject* = Shiboken::Converter< [c++ type] >::toPython(c++Obj*)
> > 
> > BR
> > 
> > On Fri, Oct 1, 2010 at 8:37 AM, Stefan Larsson <[email protected]> wrote:
> > > Hello,
> > > I am writing a C++ application using Qt4 and I am using Python embedded
> > 
> > in
> > 
> > > the application as a scripting backend for simple plugin development.
> > > My question is if it is possible to acquire a QWidget* pointer from
> > 
> > Pyside
> > 
> > > such that custom widgets written using Pyside can be embedded directly
> > > within the C++ application?  If not, would it be difficult to implement
> > 
> > such
> > 
> > > a feature?
> > > I have also looked at PythonQt, but it seems as if Pyside has better
> > > potential.
> > > Best Regards,
> > > Stefan Larsson
> > > 
> > > _______________________________________________
> > > PySide mailing list
> > > [email protected]
> > > http://lists.openbossa.org/listinfo/pyside
> > 
> > --
> > Renato Araujo Oliveira Filho
> > Instituto Nokia de Tecnologia - INdT
> > Mobile: +55 (81) 8704-2144

-- 
Hugo Parente Lima
INdT - Instituto Nokia de Tecnologia

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside

Reply via email to