Difference between revisions of "Documentation/Labs/Qt5-and-VTK8"
Max.smolens (talk | contribs) (→Status) |
Max.smolens (talk | contribs) (→Status) |
||
Line 62: | Line 62: | ||
** Fix Qt deprecation warnings. | ** Fix Qt deprecation warnings. | ||
** Find and fix layout changes. For example, some widgets likely need to set QSizePolicy::Expanding, such as the exit application confirmation dialog. | ** Find and fix layout changes. For example, some widgets likely need to set QSizePolicy::Expanding, such as the exit application confirmation dialog. | ||
− | ** Address "Policy CMP0020 is not set: Automatically link Qt executables to qtmain target on Windows" warnings. | + | ** <del>Address "Policy CMP0020 is not set: Automatically link Qt executables to qtmain target on Windows" warnings.</del> |
** Test with VTK7 (OpenGL and OpenGL2 backends). | ** Test with VTK7 (OpenGL and OpenGL2 backends). | ||
Revision as of 13:45, 28 July 2017
Home < Documentation < Labs < Qt5-and-VTK8This page documents the update of Slicer to use Qt 5.
Contents
Overview
Because Qt4 is not actively developed (as documented here support ended), we need to work toward supporting Qt5. This page summarizes support status of the various components of Slicer stack and remaining tasks.
Status
As of 2017-07-18 the relevant branches for testing are:
- Slicer: https://github.com/msmolens/Slicer/tree/support-qt5-2017-07-18-r26154 (includes VTK8)
- CTK: https://github.com/msmolens/CTK/tree/wip-support-qvtkopenglwidget
- VTK: https://github.com/Slicer/VTK/commits/slicer-v8.0.0-2017-06-26-782d7ed
To configure Slicer:
cmake -DSlicer_REQUIRED_QT_VERSION:STRING=5.7.1 -DQt5_DIR:PATH=/home/jcfr/Software/Qt5.9.1/5.9.1/gcc_64/lib/cmake/Qt5 ... ../Slicer
For VS2015 gotchas, see below.
As of 2017-06-19 this was:
https://github.com/jcfr/Slicer/tree/support-qt5-2017-06-08-r26073
- Qt5/VTK8 integration TODO:
Properly initialize QVTKOpenGLWidget. Call QSurfaceFormat::setDefaultFormat() before constructing the QApplication instance so that an OpenGL core profile context is requested.Properly initialize QVTKOpenGLWidget for tests. Call QSurfaceFormat::setDefaultFormat() before constructing the QApplication instance so that an OpenGL core profile context is requested. (Slicer, CTK)- Enable C++11 for Slicer, extensions, and libraries as appropriate.
BRAINSTools ignores configuration options and fails to configure when C++11 is enabled.DCMTK has a compile error when C++11 is enabled?. (Resolved: requires custom definition to enable C++11.)SlicerLibraries that use C++- Extensions
- Add VTK_OVERRIDE, VTK_FINAL, VTK_DELETE_FUNCTION and other necessary keywords to fix build warnings. Maintain compatibility with VTK7 by defining these as empty when using VTK7.
Set OpenGL2 as default rendering backend.CTK and Slicer QtTesting tests refer to QVTKWidget. Can they be converted to recognize QVTKOpenGLWidget?- Merge and update CTK: https://github.com/commontk/PythonQt/pull/57 ("Fix compile error on MSVC with Qt 5.7.1")
Mergeand update VTK: https://gitlab.kitware.com/vtk/vtk/merge_requests/3014 ("Fix linking libvtkWrapping with Python wrapping and kits enabled on Mac")Mergeand update VTK: https://gitlab.kitware.com/vtk/vtk/merge_requests/3041 ("QVTKOpenGLWidget: Set screen size on render window")- Fix and update VTK: https://gitlab.kitware.com/vtk/vtk/issues/17091 ("QVTKOpenGLWidget: Picking vtkActor2D fails"). In Slicer one operation this issue affects is picking slice view ROI box handles.
- Fix and update VTK: https://gitlab.kitware.com/vtk/vtk/issues/17076 ("OpenGL errors occur when destroying vtkWin32OpenGLRenderWindow") (Only affects old OpenGL backend.)
Clicking on module search result in popup does not open the module. ComboBox does not always show the selected item.- Fix Slicer test failures:
- Floating point exceptions ("SIGFPE with code FPE_FLTUND") on Mac (ModelToLabelMapTest, ModelToLabelMapTestLabelValue, N4ITKBiasFieldCorrectionTest).
- py_LandmarkRegistration crash on exit.
- qMRMLLayoutManagerWithCustomFactoryTest ("vtkPlaneSource: Bad plane coordinate system").
- ResampleDTIVolumeBSplineInterpolationTest (image diff?).
- py_VolumeRenderingThreeDOnlyLayout on Windows ("Shader object was not initialized, cannot attach it."). This is a similar issue as was fixed in r25239, but resurrected due to the behavior of QVTKOpenGLWidget. The old fix is insufficient.
- qMRMLColorPickerWidgetTest2 (CTK/Qt5 issue?).
- Fix CTK Qt5 test failures.
- OpenSSL/DataStore/qRestAPI issues?
- Packaging?
CTK needs to properly export CTK_USE_QVTKOPENGLWIDGET so that the preprocessor correctly handles #if CTK_USE_QVTKOPENGLWIDGET in its header files. Or, an alternative mechanism could be implemented.Windows/Linux: CPU and GPU Volume Rendering display nothing or are corrupt. GPU Volume Rendering gives OpenGL errors.Disabling multisampling before creating the default surface format fixes this. See https://gitlab.kitware.com/vtk/vtk/issues/17095.- Mac: Slice views use only lower-left quarter of widget.
Set Qt::AA_EnableHighDpiScaling to enable automatic scaling based on the pixel density of the monitor. This enables High DPI for platforms other than Mac.Call setEnableHiDPI(true) on QVTKOpenGLWidgets.qMRMLSliceWidget: Scale SliceView geometry by its devicePixelRatio() before calling this->SliceController->setSliceViewSize().- qMRMLSliceWidget: Observe change in devicePixelRatio (i.e. app dragged to another screen) and recompute slice view size. This requires observing the QWindow::screenChanged signal. What is the right level to connect this?
Volume Rendering transfer functions aren't displayed correctly. (ctkVTKChartView)- Fix Qt deprecation warnings.
- Find and fix layout changes. For example, some widgets likely need to set QSizePolicy::Expanding, such as the exit application confirmation dialog.
Address "Policy CMP0020 is not set: Automatically link Qt executables to qtmain target on Windows" warnings.- Test with VTK7 (OpenGL and OpenGL2 backends).
- TODOs and Notes for the current integration
- Make Qt5.7.1 the required version if version greater than Qt5.6; a QWebEngine bug: https://bugreports.qt.io/browse/QTBUG-54762 was resolved in 5.7.1.
- Windows:
- Tested build: VS2013, Qt5.7.1 downloaded from Qt's official releases.
- 2017-07-18: http://slicer.cdash.org/viewTest.php?onlyfailed&buildid=1065056
SlicerLauncherSettings.ini need to include path to Qt bin directory. Doing this manually right now- VS2015:
- Configure with
-DSlicer_USE_PYTHONQT_WITH_OPENSSL:BOOL=OFF
- Python 2.7: This patch should be applied. See https://github.com/python-cmake-buildsystem/python-cmake-buildsystem/issues/161
- DCMTK: To fix "DCMTK was configured to use the C++11 STL, [...]" error. Edit
C:\path\to\S-bld\DCMTK\CMake\osconfig.h.in
and comment lines highlighted in https://github.com/commontk/DCMTK/blob/d8ed091cda2b815226eafe41f5b4fe3bd22f8d5d/CMake/osconfig.h.in#L1096-L1100- To understand why: See https://blogs.msdn.microsoft.com/vcblog/2016/06/07/standards-version-switches-in-the-compiler/
- From Microsoft:
We won’t update __cplusplus until the compiler fully conforms to the standard. Until then, you can check the value of _MSVC_LANG.
- Or, could change logic in SuperBuild/External_DCMTK.cmake to only enable C++11 for UNIX platforms.
- Configure with
- VS2015:
- Linux:
- Tested build: Ubuntu 16.04, gcc, Qt5.7.1 downloaded from Qt's official releases, multiple PCs:
- 2017-07-17: http://slicer.cdash.org/viewTest.php?onlyfailed&buildid=1064395
- 2017-07-17: http://slicer.cdash.org/viewTest.php?onlyfailed&buildid=1064396
- MacOSX:
- Tested build: Qt5.7.1 built from scratch with openssl support, MacOSX10.11
- 2017-07-18: http://slicer.cdash.org/viewTest.php?onlyfailed&buildid=1064397
- NOTE: WIP qt-easy-build to build Qt5.7.1 with OpenSSL support: https://github.com/msmolens/qt-easy-build/commits/wip-qt5; based on https://github.com/jcfr/qt-easy-build/pull/32
Need to address manual install of the sql and cocoa plugin and platform files for sql and cocoa.
- Original branch:
https://github.com/jcfr/Slicer/commits/support-qt5
- Work-in-progress branch that partially builds
- 2017-01:
- 2016-12:
- Superbuild configure command on mac using Qt 5.7 stock downloads
cmake \ -DQT_QMAKE_EXECUTABLE:FILEPATH=/Users/pieper/Qt/5.7/clang_64/bin/qmake \ -DCMAKE_PREFIX_PATH:PATH=/Users/pieper/Qt/5.7/clang_64/ \ -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9 \ -DSlicer_USE_PYTHONQT_WITH_TCL:BOOL=OFF \ -DSlicer_USE_SimpleITK:BOOL=OFF \ -DSlicer_USE_QtTesting:BOOL=OFF \ -DSlicer_BUILD_EXTENSIONMANAGER_SUPPORT:BOOL=OFF \ -DSlicer_QT_VERSION:STRING=5 \ ../Slicer
Platform Notes
Experimental build on Window:
- Visual Studio Community 2015
- Qt 5.7
- Include QtWebEngine and QtScript during install
- Select 2015 64 bit install
- Qt 5.8
- Use Visual Studio Community 2015 or above. Qt-5.8 does not support QtWebEngine for msvc 2013.
Known Issues
- Slice viewers do not have the expected size after changing layout
To Do List
All platforms
- Slicer build system upgrade: To be done
Add Slicer_QT_VERSION option that could be set to either 4 or 5 - See what is done in CTK- Fix qRestAPI to support Qt5 (or turn off Slicer_BUILD_EXTENSIONMANAGER_SUPPORT for testing)
- See
Update use of QT4_* macros (see below) - See what is done in CTK- Port from QtWebKit to QtWebEngine
- Update of classes using WebKit to work with
WebEngineView
(these includes "Extension Manager", "Data Store", "Chart View" and `qMRMLExpandingWebView`). - `qSlicerWebWidget` should be improved, moved to CTK and used for all widgets making use of a web view.
- Update of classes using WebKit to work with
update PythonQt to the latest Qt version- Look at updating PythonQt to support QWebEngine
Fix differences in plugin loading- Update packaging scripts (SlicerBlockInstallQt.cmake, SlicerCPackBundleFixup.cmake)
- Update build script to support qt5 (see https://github.com/jcfr/qt-easy-build )
- Update Slicer build instruction on developer wiki
Qt5::Network is now a dependency of Base/QTCore (Networking module in Qt5 has classes like QNetworkProxyFactory that were in Qt4's QtCore module)- Transparency is handled differently: see problem in this discussion thread http://vtk.1045678.n5.nabble.com/Strange-renderering-with-mixed-polydata-volume-with-QVTKOpenGLWidget-td5743309.html and a related fix in ITKSnap https://github.com/pyushkevich/itksnap/blob/master/GUI/Qt/main.cxx#L572-L574 and
- Command line arguments to expose webgl and webengine debugging
./Slicer-build/Slicer --enable-experimental-web-platform-features --enable-unsafe-es3-apis --remote-debugging-port=12117 --use-gl=desktop
CTK Python wrapping doesn't expose grabWidget.
Linux
- fix fox `libpng warning: iCCP: known incorrect sRGB profile`
Minimal working release experimental build (no cli, ssl, simpleitk, ...) built on ubuntu 16.04, tested on debian 8
- needed to manually copy shared libraries:
- libasound.so.2
- libxslt.so.1
- libsmime3
- libstdc++.so.6 (glibc mismatch, needed GLIBCXX_3.4.21) should build instead with manylinux
- like on mac, need to create bin/platfrms and bin/sqldrivers and copy in platforms/libqxcb.so and sqldrivers/libqsqlite.so
Mac
on Mac, QT_NO_OPENSSL is defined, but so is QSslError leading to redefined symbol [1](here).Mac crash in qSlicerUnitsSettingsPanelPrivate::addQuantity, appears to be corrupted model.partly addressed by r25855 , finally resolved r25883. Most expedient solution is probably to disable the units settings panel in the application settings since is not widely used in the application.- Add libqcocoa.dylib and libqsqlite.dylib to package for mac
mkdir Slicer-build/bin/Slicer.app/Contents/MacOS/sqldrivers cp ~/Qt/5.7/clang_64/plugins/sqldrivers/libqsqlite.dylib Slicer-build/bin/Slicer.app/Contents/MacOS/sqldrivers/ mkdir Slicer-build/bin/Slicer.app/Contents/MacOS/platforms cp ~/Qt/5.7/clang_64/plugins/platforms/libqcocoa.dylib Slicer-build/bin/Slicer.app/Contents/MacOS/platforms/
- Workarounds here:
https://gist.github.com/pieper/59de820ad08cf3c0f7a33926397e612d
Windows
qtstyleplugins library needs to be removed or ported to support windows- add declspec exports/imports
- create .lib for use in QTGUI
- support shared/static build?
- AppLauncher settings need to be update
- Debug build runs very slowly - can it be improved? Build is very slow too, but the application runs so slowly in debug mode that it is basically unusable (this is a change from previous version that were usable for testing real workflows in debug mode).
- Setting Slicer_USE_SimpleITK to ON in CMake results in compile-time errors.
- Creating a debug build (MSVC 2013, Qt5.7) creates a compile time error on PythonQt.cpp while building the CTK project with message:
Error 1220 error C1128: number of sections exceeded object file format limit: compile with /bigobj
Example starting point command:
cmake \ -DQt5_DIR:FILEPATH=c:/Qt/5.7/msvc2013_64/lib/cmake/Qt5 \ -DCMAKE_CONFIGUREATION_TYPES:STRING=Release \ -DADDITIONAL_C_FLAGS:STRING=" /MP8" \ -DADDITIONAL_CXX_FLAGS:STRING=" /MP8" \ -DSlicer_USE_PYTHONQT_WITH_TCL:BOOL=OFF \ -DSlicer_USE_SimpleITK:BOOL=OFF \ -DSlicer_USE_QtTesting:BOOL=OFF \ -DSlicer_BUILD_EXTENSIONMANAGER_SUPPORT:BOOL=OFF \ -DSlicer_BUILD_DataStore:BOOL=OFF \ -DSlicer_QT_VERSION:STRING=5 \ -DBUILD_TESTING:BOOL=OFF \ -G"Visual Studio 12 2013 Win64" \ c:/pieper/slicer4/latest/Slicer
SuperBuild Dependencies
- PythonQt:
Done- Need to update to Qt 5.7 in current PythonQt trunk (currently 5.6) and CommonTK PythonQt (currently 5.4)
- Need to merge fix for MSVC Debug build: https://github.com/commontk/PythonQt/pull/57
- CTK support: Potential minor issues
- ctkColorDialog implementation possibly incompatible with Qt5. Run Slicer test qMRMLColorPickerWidgetTest2. ctkColorDialog makes assumptions about QColorDialog's layout.
- Some tests fail.
- VTK
- Usage of QT4_ macros:
$ ack --cmake -i "qt4" CMake/SlicerMacroBuildModuleQtLibrary.cmake 116: QT4_WRAP_CPP(MODULEQTLIBRARY_MOC_OUTPUT ${MODULEQTLIBRARY_MOC_SRCS}) 118: QT4_WRAP_UI(MODULEQTLIBRARY_UI_CXX ${MODULEQTLIBRARY_UI_SRCS}) 121: QT4_ADD_RESOURCES(MODULEQTLIBRARY_QRC_SRCS ${MODULEQTLIBRARY_RESOURCES}) 127: QT4_ADD_RESOURCES(MODULEQTLIBRARY_QRC_SRCS ${Slicer_LOGOS_RESOURCE}) CMake/SlicerMacroTranslation.cmake 83: QT4_CREATE_TRANSLATION(QM_OUTPUT_FILES ${FILES_TO_TRANSLATE} ${TS_FILES}) 85: QT4_ADD_TRANSLATION(QM_OUTPUT_FILES ${TS_FILES}) CMake/SlicerMacroBuildQtModule.cmake 132: QT4_WRAP_CPP(LOADABLEMODULE_MOC_OUTPUT ${LOADABLEMODULE_MOC_SRCS}) 134: QT4_WRAP_UI(LOADABLEMODULE_UI_CXX ${LOADABLEMODULE_UI_SRCS}) 137: QT4_ADD_RESOURCES(LOADABLEMODULE_QRC_SRCS ${LOADABLEMODULE_RESOURCES}) 143: QT4_ADD_RESOURCES(LOADABLEMODULE_QRC_SRCS ${Slicer_LOGOS_RESOURCE}) CMake/SlicerMacroBuildApplication.cmake 141: QT4_WRAP_CPP(SLICERAPPLIB_MOC_OUTPUT ${SLICERAPPLIB_MOC_SRCS}) 142: QT4_WRAP_UI(SLICERAPPLIB_UI_CXX ${SLICERAPPLIB_UI_SRCS}) 144: QT4_ADD_RESOURCES(SLICERAPPLIB_QRC_SRCS ${SLICERAPPLIB_RESOURCES}) CMake/SlicerBlockFindQtAndCheckVersion.cmake 22:# The CMake code used to find Qt4 has been factored out into this CMake script so that 27: find_package(Qt4) 28: if(NOT QT4_FOUND) CMake/SlicerMacroBuildBaseQtLibrary.cmake 35:# using QT4_WRAP_CPP CMake macro 38:# QT4_WRAP_UI CMake macro 47:# using QT4_ADD_RESOURCES 141: QT4_WRAP_CPP(SLICERQTBASELIB_MOC_OUTPUT ${SLICERQTBASELIB_MOC_SRCS}) 142: QT4_WRAP_UI(SLICERQTBASELIB_UI_CXX ${SLICERQTBASELIB_UI_SRCS}) 144: QT4_ADD_RESOURCES(SLICERQTBASELIB_QRC_SRCS ${SLICERQTBASELIB_RESOURCES}) 147: QT4_ADD_RESOURCES(SLICERQTBASELIB_QRC_SRCS ${Slicer_SOURCE_DIR}/Resources/qSlicer.qrc) Modules/Loadable/Models/Testing/Cxx/CMakeLists.txt 15:QT4_GENERATE_MOCS( Modules/Loadable/Transforms/Testing/Cxx/CMakeLists.txt 9:QT4_GENERATE_MOCS( Modules/Loadable/VolumeRendering/Testing/Cxx/CMakeLists.txt 36:QT4_GENERATE_MOCS( Libs/MRML/Widgets/CMakeLists.txt 363:QT4_WRAP_CPP(MRMLWidgets_MOC_CXX ${MRMLWidgets_MOC_SRCS}) 364:QT4_WRAP_UI(MRMLWidgets_UI_CXX ${MRMLWidgets_UI_SRCS}) 365:QT4_ADD_RESOURCES(MRMLWidgets_QRC_CXX ${MRMLWidgets_QRC_SRCS}) Libs/MRML/Widgets/Testing/CMakeLists.txt 139:QT4_WRAP_CPP(Tests_MOC_CXX ${Tests_MOC_SRCS}) 140:QT4_GENERATE_MOCS( CMakeLists.txt 570:# Module name should be specified as they appear in FindQt4.cmake Base/QTCore/Testing/Cxx/CMakeLists.txt 37: QT4_GENERATE_MOCS( 42: QT4_GENERATE_MOCS( 49: QT4_GENERATE_MOCS( 54: QT4_ADD_RESOURCES(Tests Resources/${KIT}Testing.qrc) 60: list(APPEND KIT_TEST_TARGET_LIBRARIES Qt4::QtTest) Base/QTGUI/Testing/Cxx/CMakeLists.txt 45: QT4_GENERATE_MOCS(${KIT_TEST_MOC_SRCS}) 48: QT4_ADD_RESOURCES(Tests Resources/${KIT}Testing.qrc)
Migration Guide
To do items (partial list):
- update loadable modules to use new plugin macros
- any use of QWebKit needs to switch to QWebEngine
List of extensions that may require updates
TBD (probably all extensions need work)
Future works
NA