File: transfer_ownership.hh

package info (click to toggle)
openstructure 2.9.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 205,228 kB
  • sloc: cpp: 188,129; python: 35,361; ansic: 34,298; fortran: 3,275; sh: 286; xml: 146; makefile: 29
file content (26 lines) | stat: -rw-r--r-- 698 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef OST_GUI_PYMOD_TRANSFER_OWNERSHIP_HH
#define OST_GUI_PYMOD_TRANSFER_OWNERSHIP_HH

/*
  Author: Marco Biasini
 */

#include <boost/python.hpp>


namespace ost { namespace gui {

inline void TransferOwnership(QWidget* obj)
{
  boost::python::object main_module=boost::python::import("__main__");  
  boost::python::object qt_gui=boost::python::import("PyQt5.QtGui");
  boost::python::object pobj(reinterpret_cast<unsigned long>(obj));
  boost::python::object sip=main_module.attr("sip");
  boost::python::object type=qt_gui.attr("QWidget");
  boost::python::object wrapped_obj=sip.attr("wrapinstance")(pobj, type);
  sip.attr("transferto")(wrapped_obj, boost::python::object());
}

}}

#endif