[vtkusers] PyQt and VTK - Qt version number

Clinton Stimpson clinton at elemtech.com
Wed Nov 3 15:22:22 EDT 2010


On Wednesday, November 03, 2010 01:11:54 pm Jeff Baumes wrote:
> This may or may not be related to the recent post about PyQt and VTK, but I
> thought I'd start it in a different thread. I've also had trouble compiling
> VTK with VTK_WRAP_PYTHON_SIP. GUISupport/Qt/CMakeLists.txt assumes that the
> "-t" flag sent to sip should match the current Qt version. But from what I
> could find online, the "-t" flag does not correspond to the Qt version, but
> the API version that is being wrapped with sip. The actual value that
> should be used for the "-t" flag seems to be in PyQt's pyqtconfig.py:
> 
> # These are installation specific values created when PyQt4 was configured.
> _pkg_config = {
>     'pyqt_bin_dir':
>  '/System/Library/Frameworks/Python.framework/Versions/2.6/bin',
>     'pyqt_config_args':  '',
>     'pyqt_mod_dir':      '/Library/Python/2.6/site-packages/PyQt4',
>     'pyqt_modules':      'QtCore QtGui QtHelp QtMultimedia QtNetwork
> QtOpenGL QtScript QtScriptTools QtSql QtSvg QtTest QtWebKit QtXml
> QtXmlPatterns phonon QtDesigner',
>     'pyqt_sip_dir':
>  '/System/Library/Frameworks/Python.framework/Versions/2.6/share/sip/PyQt4'
> , 'pyqt_sip_flags':    '-x VendorID -t WS_MACX -x PyQt_NoPrintRangeBug -t
> Qt_4_6_3 -x Py_v3 -g',
>     'pyqt_version':      0x040704,
>     'pyqt_version_str':  '4.7.4',
>     'qt_data_dir':       '/usr/local/Qt4.7',
>     'qt_dir':            '/',
>     'qt_edition':        'free',
>     'qt_framework':      1,
>     'qt_inc_dir':        '/usr/include',
>     'qt_lib_dir':        '/Library/Frameworks',
>     'qt_threaded':       1,
>     'qt_version':        0x040700,
>     'qt_winconfig':      'shared'
> }
> 
> Note the mismatch between the pyqt_sip_flags and pyqt_version_str. When I
> applied the following patch to explicitly set the flag to what is in
> pyqt_sip_flags, it worked with no errors:
> 
> --- a/GUISupport/Qt/CMakeLists.txt
> +++ b/GUISupport/Qt/CMakeLists.txt
> @@ -279,7 +279,8 @@ if(VTK_WRAP_PYTHON_SIP)
>    elseif(Q_WS_MAC)
>      set(SIP_FLAGS ${SIP_FLAGS} -t WS_MACX)
>    endif()
> -  set(SIP_FLAGS ${SIP_FLAGS} -t
> Qt_${QT_VERSION_MAJOR}_${QT_VERSION_MINOR}_0)
> +  set(SIP_FLAGS ${SIP_FLAGS} -t Qt_4_6_3)
>    set(SIP_FLAGS ${SIP_FLAGS}
>      -I ${SIP_PYQT_DIR}
>      -I ${CMAKE_CURRENT_SOURCE_DIR}
> 
> Anyone know why this mismatch exists? Should the CMakeLists file somehow
> extract this from pyqtconfig.py instead of assuming the versions match?
> 
> Jeff

The mismatch exists because the PyQt you are using hasn't been updated to the 
Qt 4.7 api.  So in your case, you are getting only the Qt 4.6 api from Qt 4.7 
available in Python.

GUISupport/Qt/CMakeLists.txt makes the assumption that your PyQt version 
matches your Qt version.
But yes, it would be better to not make that assumption.

Clint



More information about the vtkusers mailing list