Skip to content
Snippets Groups Projects
Select Git revision
  • 3a76353dc7370e67a51f266434e19c762f4d6446
  • master default protected
  • develop protected
  • cmake_boost_refactor
  • ubuntu_ci
  • mmtf
  • non-orthogonal-maps
  • no_boost_filesystem
  • data_viewer
  • 2.11.1
  • 2.11.0
  • 2.10.0
  • 2.9.3
  • 2.9.2
  • 2.9.1
  • 2.9.0
  • 2.8.0
  • 2.7.0
  • 2.6.1
  • 2.6.0
  • 2.6.0-rc4
  • 2.6.0-rc3
  • 2.6.0-rc2
  • 2.6.0-rc
  • 2.5.0
  • 2.5.0-rc2
  • 2.5.0-rc
  • 2.4.0
  • 2.4.0-rc2
29 results

python_cpp.rst

Blame
  • python_cpp.rst 1.04 KiB

    Mixing PyQt and C++ Widgets

    PyQt5 is a set of Python bindings for Qt5. The exposure from C++ to Python is done with SIP, which has a different mechanism than boost::python.

    To access a exported boost::python Qt-Object from Python we provide a method which wraps the Object into a Python SIP Object.

    seq_viewer = gui.SequenceViewer() # Create SequenceViewer Object
    qobj = seq_viewer.qobject #Get Python SIP Object
    print(qobj.size())   # Call function on QWidget

    The other way around, each boost::python Qt Object accepts Python objects as input for Qt Objects. It handles the cast to a C++ Qt Object internally.

    from PyQt5 import QtWidgets
    persp = gui.GostyApp.Instance().perspective
    test = persp.GetMenu("Test") #Get boost::python qobject
    test_action = QtWidgets.QAction('&Test me', test) #Create Python SIP Object
    test.addAction(test_action) #Add Action to boost::python object