How to get VTK9 + Qt6 working together?

@sankhesh got it to working (barely), locally of course, after these fixes in the CMake Configure phase (Mac OS 10.14.6 Mojave, Clang 10.0.1):

  • Update git tag -a 9.0.1 -m "my msg" – could have been a bad local tag.
  • I had to hand-update Qt6XYZ_DIR variables for say, 5 out of 7 or so (so I had to Configure five times just for these variables).
  • Replace Qt5 with Qt6 in GUISupport/QtSql/CMakeLists.txt.
  • Couldn’t get rid of Qt5_DIR errors while building Testing for the above, so disabled build of any VTK test.

That meant I was able to Generate. I had to do these fixes in the make phase:

  • QFontMetricsF::width() has been obsoleted, and so replaced with its equivalent horizontalAdvance() method in Rendering/Qt/vtkQtTreeRingMapper.cxx, .h files.
  • Likewise in Views/Qt/vtkQtListView.h, .cpp, vtkQtTreeView.h, .cpp, replace class QRegExp instance with that of class QRegularExpression, and QSortFilterProxyModel::setFilterRegExp() method with its setFilterRegularExpression().
  • We are almost there … Views/Qt/CMakeLists.txt had Qtn:Widgets instead of Qtn::Widgets in its module link command!

Voila! Finally, I was on my way.

So I was able to build VTK9 + Qt6, and run Draw Sphere, the Hello World of VTK, but with a twist. @ben.boeckel was right (not able to mention Mathieu or Utkar): QVTKOpenGLNativeWidget is not positioned properly in the Main Window (always at the left bottom as opposed to where I put it), and the sphere keeps on spinning (should spin only when you click and drag).

If it helps, I am happy to put my little Qt+Vtk project on GitHub and send you the link. Thank you all for responding in the middle of holidays. Happy New Year!!