Skip to content

Commit 3a34afb

Browse files
authored
Updating to Qt 6 (#523)
* Remove some deprecated calls. * Update CMake Lists * Update OIGTL/OIGTLIO * VTK fix * The macro SendMessage in winuser.h clashes with the method name in igtlioConnector. I would guess Qt6 now includes this somewhere where Qt5 wasn't. The cleaner way to resolve this would be to rename the SendMessage method in OIGTLIO to something unique, but this would require also changing every other application using OIGTLIO. * Update Windows and Linux CI to build with Qt6
1 parent 58a4622 commit 3a34afb

38 files changed

+165
-210
lines changed

.github/workflows/build-windows.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build-Windows
33
on: [push, pull_request]
44
env:
55
BUILD_TYPE: Release
6-
QT_VERSION: 5.15.2
6+
QT_VERSION: 6.9.0
77
ARTIFACT: ibis-install-windows
88
RELEASE_TAG: latest_dev
99
permissions:
@@ -24,7 +24,7 @@ jobs:
2424
-B ${{github.workspace}}/b \
2525
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
2626
-DCMAKE_CONFIGURATION_TYPES=${{env.BUILD_TYPE}} \
27-
-DQt5_DIR=C:/Qt/5.15.2/msvc2019_64/lib/cmake/Qt5 \
27+
-DQt6_DIR=C:/Qt/${{env.QT_VERSION}}/msvc2022_64/lib/cmake/Qt6 \
2828
-DIBIS_BUILD_ELASTIX=TRUE \
2929
-DIBIS_BUILD_OPENCV=TRUE \
3030
-DIBIS_BUILD_ALL_PLUGINS:BOOL=TRUE

.github/workflows/build_linux.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Build-Linux
33
on: [push, pull_request]
44
env:
55
BUILD_TYPE: Release
6+
QT_VERSION: 6.9.0
67
ARTIFACT: ibis-install-linux
78
permissions:
89
contents: write
@@ -20,6 +21,7 @@ jobs:
2021
cmake IbisSuperBuild \
2122
-B "${{github.workspace}}/b" \
2223
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
24+
-DQt6_DIR=/opt/Qt/${{env.QT_VERSION}}/gcc_64/lib/cmake/Qt6 \
2325
-DIBIS_BUILD_ELASTIX=TRUE \
2426
-DIBIS_BUILD_OPENCV=TRUE \
2527
-DIBIS_BUILD_ALL_PLUGINS:BOOL=TRUE

CMakeCommon/windeployqt.cmake

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23-
find_package(Qt5Core REQUIRED)
23+
find_package(Qt6Core REQUIRED)
2424

2525
# Retrieve the absolute path to qmake and then use that path to find
2626
# the windeployqt binary
27-
get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION)
27+
get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION)
2828
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
2929
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}")
3030

@@ -44,7 +44,6 @@ function(windeployqt target directory)
4444
env PATH="${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}"
4545
--verbose 0
4646
--no-compiler-runtime
47-
--no-angle
4847
--no-opengl-sw
4948
\"$<TARGET_FILE:${target}>\"
5049
)
@@ -65,7 +64,6 @@ function(windeployqt target directory)
6564
env PATH=\"${_qt_bin_dir}\" \"${WINDEPLOYQT_EXECUTABLE}\"
6665
--dry-run
6766
--no-compiler-runtime
68-
--no-angle
6967
--no-opengl-sw
7068
--list mapping
7169
\${_file}

CMakeLists.txt

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ include( ${CMAKE_COMMON_DIR}/DependencyVersions.cmake )
2828
set( IBIS_EXTERNAL_DEPENDENCIES_DIR ${CMAKE_CURRENT_BINARY_DIR}/../IbisDeps CACHE PATH "Path where the external dependencies (itk, vtk, openCV) have been built" )
2929

3030
#==================================================================
31-
# Look for QT5 (required)
31+
# Look for QT6 (required)
3232
#==================================================================
3333
option( IBIS_USE_QT_MULTIMEDIA "Find and link with the Multimedia module in Qt. This is not required by Ibis but may be used by some plugins." OFF )
3434
option( IBIS_USE_QT_NETWORK "Find and link with the Network module in Qt. This is not required by Ibis but may be used by some plugins." OFF )
@@ -39,28 +39,18 @@ endif()
3939
if( IBIS_USE_QT_NETWORK )
4040
list( APPEND IbisQtModules Network )
4141
endif()
42-
if( UNIX AND NOT APPLE )
43-
list( APPEND IbisQtModules X11Extras )
44-
endif()
45-
find_package( Qt5 COMPONENTS ${IbisQtModules} REQUIRED )
4642

47-
# Qt support by Qt Company: QT 5.1.0 to 5.5.0 support ended. 5.6.0 still supported until March 2019.
48-
# ibis was never tested with versions 5.6.0, 5.7.0 and 5.8.0. It might work with 5.8.0.
49-
# it worked with 5.9.3
43+
find_package( Qt6 COMPONENTS ${IbisQtModules} REQUIRED )
5044

51-
if( Qt5Widgets_FOUND )
52-
if( Qt5Widgets_VERSION VERSION_LESS 5.6.0 )
53-
message( SEND_ERROR "Qt version 5.5.x or lower is no longer supported.\nCurrently supported Qt version is 5.9 and higher.\nYou are using " ${Qt5Widgets_VERSION} "." )
54-
elseif( Qt5Widgets_VERSION VERSION_LESS 5.9.0 )
55-
message( SEND_ERROR "Currently supported Qt version is 5.9 and higher.\nYou are using " ${Qt5Widgets_VERSION} ". It may work." )
56-
endif()
57-
else()
58-
message( SEND_ERROR "The Qt5Widgets library could not be found!" )
45+
if( NOT Qt6Widgets_FOUND )
46+
message( SEND_ERROR "The Qt6Widgets library could not be found!" )
5947
endif()
6048

61-
include_directories( ${Qt5Widgets_INCLUDE_DIRS} )
62-
include_directories( ${Qt5Xml_INCLUDE_DIRS} )
63-
include_directories( ${Qt5Multimedia_INCLUDE_DIRS} )
49+
cmake_path(GET Qt6_DIR PARENT_PATH Qt6_root)
50+
51+
include_directories( ${Qt6Widgets_INCLUDE_DIRS} )
52+
include_directories( ${Qt6Xml_INCLUDE_DIRS} )
53+
include_directories( ${Qt6Multimedia_INCLUDE_DIRS} )
6454

6555
#==================================================================
6656
# Look for VTK (required)
@@ -125,7 +115,7 @@ endif()
125115

126116
# define version and build info
127117
set( IBIS_MAJOR_VERSION 4 )
128-
set( IBIS_MINOR_VERSION 0 )
118+
set( IBIS_MINOR_VERSION 1 )
129119
set( IBIS_PATCH_VERSION 0 )
130120
set( IBIS_VERSION_QUALIFIER "Dev" ) # Dev, Alpha, Beta or nothing for official releases
131121
if( CMAKE_BUILD_TYPE MATCHES "Debug" )
@@ -178,4 +168,4 @@ if( IBIS_BUILD_DOCUMENTATION )
178168
else( DOXYGEN_FOUND )
179169
message( "Doxygen needs to be installed to generate documentation" )
180170
endif()
181-
endif()
171+
endif()

Ibis/CMakeLists.txt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PROJECT ( IBIS_MAIN )
22

33
# define sources
4-
SET( IBIS_SRC main.cpp commandlinearguments.cpp )
5-
SET( IBIS_HDR commandlinearguments.h )
4+
set( IBIS_SRC main.cpp commandlinearguments.cpp )
5+
set( IBIS_HDR commandlinearguments.h )
66
set( exec_name ibis )
77

88
# option to turn on vtk warnings
@@ -12,7 +12,7 @@ if( NOT IBIS_ENABLE_VTK_WARNINGS )
1212
endif()
1313

1414
# moc Qt source file without a ui file
15-
qt5_wrap_cpp( IBIS_MOC ${IBIS_HDR_MOC} )
15+
qt6_wrap_cpp( IBIS_MOC ${IBIS_HDR_MOC} )
1616

1717
# make rules to create c++ source from Qt resource files
1818

@@ -70,7 +70,7 @@ endif()
7070
#================================
7171
# Define executable
7272
#================================
73-
SET( SOURCE ${IBIS_HDR} ${IBIS_HDR_MOC} ${IBIS_SRC} ${ImportPluginsSourceFile} ${IBIS_MOC} ${IBIS_SRC_ICNS} ${platform_src} )
73+
set( SOURCE ${IBIS_HDR} ${IBIS_HDR_MOC} ${IBIS_SRC} ${ImportPluginsSourceFile} ${IBIS_MOC} ${IBIS_SRC_ICNS} ${platform_src} )
7474
ADD_EXECUTABLE( ${exec_name} ${executable_flags} ${SOURCE} )
7575

7676
if (APPLE)
@@ -90,10 +90,13 @@ if( USE_POINT_GREY_CAMERA )
9090
set( flycaptureLib flycapture )
9191
endif()
9292

93-
TARGET_LINK_LIBRARIES( ${exec_name} ${PluginLibs} ${PluginExternalLibs} ${HardwareModulesLibs} ${libsToUse} ${QT_LIBRARIES}
94-
${VTK_LIBRARIES} ${MINC4ITK_LIBRARIES} ${ELASTIX_LIBRARIES}
93+
target_link_libraries( ${exec_name} ${PluginLibs} ${PluginExternalLibs} ${HardwareModulesLibs} ${libsToUse}
94+
${VTK_LIBRARIES} ${MINC4ITK_LIBRARIES} ${ELASTIX_LIBRARIES}
9595
${itkLibsToUse} ${OpenCV_LIBS} ${flycaptureLib} svl ${gpuLibs} )
96-
qt5_use_modules( ${exec_name} ${IbisQtModules} )
96+
foreach( module IN LISTS IbisQtModules )
97+
message( STATUS "Linking against Qt6::${module}" )
98+
target_link_libraries( ${exec_name} "Qt6::${module}" )
99+
endforeach()
97100

98101
vtk_module_autoinit( TARGETS ${exec_name} MODULES ${VTK_LIBRARIES})
99102

@@ -117,7 +120,7 @@ endif()
117120
#================================
118121
if( APPLE )
119122
# On mac, we need to run macdeployqt on the installed bundle (should eventually implement a better solution)
120-
get_target_property( QMakeLocation Qt5::qmake LOCATION)
123+
get_target_property( QMakeLocation Qt6::qmake LOCATION)
121124
get_filename_component( QtBinLocation ${QMakeLocation} DIRECTORY )
122125
set( MacDeployQtExec ${QtBinLocation}/macdeployqt )
123126
set( BuiltExecFullPath ${CMAKE_CURRENT_BINARY_DIR}/${exec_name}.app )
@@ -148,7 +151,7 @@ endif()
148151
#================================
149152
set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Ibis image-guided neurosurgery program and viewer")
150153
set( CPACK_PACKAGE_NAME ${exec_name} )
151-
set( CPACK_PACKAGE_CONTACT "Simon Drouin and Anka Kochanowska")
154+
set( CPACK_PACKAGE_CONTACT "Étienne Léger")
152155
set( CPACK_PACKAGE_VENDOR "NeuroImaging and Surgical Technologies (NIST) Lab - McConnell Brain Imaging Centre - Montreal Neurological Institute")
153156
set( CPACK_PACKAGE_VERSION_MAJOR ${IBIS_MAJOR_VERSION})
154157
set( CPACK_PACKAGE_VERSION_MINOR ${IBIS_MINOR_VERSION})

IbisHardwareIGSIO/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ set( IbisHardwareIgsioHdrMoc ibishardwareIGSIO.h plusserverinterface.h ibishardw
2121
set( IbisHardwareIgsioUi ibishardwareIGSIOsettingswidget.ui )
2222

2323
# moc Qt source file without a ui file
24-
qt5_wrap_cpp( IbisHardwareIgsioMoc ${IbisHardwareIgsioHdrMoc} )
24+
qt6_wrap_cpp( IbisHardwareIgsioMoc ${IbisHardwareIgsioHdrMoc} )
2525

2626
# Generate code for .ui files -> ui_xxx.h
27-
qt5_wrap_ui( IbisHardwareIgsioUiHdr ${IbisHardwareIgsioUi} )
27+
qt6_wrap_ui( IbisHardwareIgsioUiHdr ${IbisHardwareIgsioUi} )
2828

2929
#================================
3030
# Define output

IbisHardwareIGSIO/ibishardwareIGSIO.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ See Copyright.txt or http://ibisneuronav.org/Copyright.html for details.
4141
#include "qIGTLIOLogicController.h"
4242
#include "usprobeobject.h"
4343

44+
#undef SendMessage
45+
4446
const double IbisHardwareIGSIO::MaxTimeBetweenTransformSamples = 0.2;
4547
const QString IbisHardwareIGSIO::PlusServerExecutable = "PlusServerExecutable";
4648

IbisLib/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,14 @@ set( IBISLIB_UI
183183

184184

185185
# moc Qt source file without a ui file
186-
qt5_wrap_cpp( IBISLIB_MOC ${IBISLIB_HDR_MOC} )
186+
qt6_wrap_cpp( IBISLIB_MOC ${IBISLIB_HDR_MOC} )
187187

188188
# Generate code for .ui files -> ui_xxx.h
189-
qt5_wrap_ui( IBISLIB_HDR_UI ${IBISLIB_UI} )
189+
qt6_wrap_ui( IBISLIB_HDR_UI ${IBISLIB_UI} )
190190

191191
# make rules to create c++ source from Qt resource files
192192
set( IBISLIB_RCC IbisLib.qrc )
193-
qt5_add_resources( IBISLIB_RCC_SRC ${IBISLIB_RCC})
193+
qt6_add_resources( IBISLIB_RCC_SRC ${IBISLIB_RCC})
194194

195195
#================================
196196
# Define output

IbisLib/application.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void ApplicationSettings::LoadSettings( QSettings & settings )
7171
ViewBackgroundColor.setGreen( settings.value( "ViewBackgroundColor_g", 50 ).toInt() );
7272
ViewBackgroundColor.setBlue( settings.value( "ViewBackgroundColor_b", 50 ).toInt() );
7373
// then 3D view, if not found in settings, set the same as 2D.
74-
double bgColor[3];
74+
float bgColor[3];
7575
ViewBackgroundColor.getRgbF( &bgColor[0], &bgColor[1], &bgColor[2] );
7676
View3DBackgroundColor.setRed( settings.value( "View3DBackgroundColor_r", int( bgColor[0] * 255 ) ).toInt() );
7777
View3DBackgroundColor.setGreen( settings.value( "View3DBackgroundColor_g", int( bgColor[1] * 255 ) ).toInt() );
@@ -221,14 +221,17 @@ Application::~Application()
221221

222222
void Application::ApplyApplicationSettings()
223223
{
224-
double bgColor[3];
224+
float bgColor[3] = {0., 0., 0.};
225225
m_settings.ViewBackgroundColor.getRgbF( &bgColor[0], &bgColor[1], &bgColor[2] );
226-
m_sceneManager->SetViewBackgroundColor( bgColor );
227-
m_settings.View3DBackgroundColor.getRgbF( &bgColor[0], &bgColor[1], &bgColor[2] );
228-
m_sceneManager->SetView3DBackgroundColor( bgColor );
226+
double bgColord[3] = { bgColor[0], bgColor[1], bgColor[2] };
227+
m_sceneManager->SetViewBackgroundColor( bgColord );
228+
float bg3DColor[3] = {0., 0., 0.};
229+
m_settings.View3DBackgroundColor.getRgbF( &bg3DColor[0], &bg3DColor[1], &bg3DColor[2] );
230+
double bg3DColord[3] = { bg3DColor[0], bg3DColor[1], bg3DColor[2] };
231+
m_sceneManager->SetView3DBackgroundColor( bg3DColord );
229232
m_sceneManager->Set3DCameraViewAngle( m_settings.CameraViewAngle3D );
230233

231-
double cursorColor[3];
234+
float cursorColor[3] = {0., 0., 0.};
232235
m_settings.CutPlanesCursorColor.getRgbF( &cursorColor[0], &cursorColor[1], &cursorColor[2] );
233236
WorldObject * world = WorldObject::SafeDownCast( m_sceneManager->GetSceneRoot() );
234237
world->SetCursorColor( cursorColor );
@@ -445,7 +448,7 @@ void Application::OpenFiles( OpenFileParams * params, bool addToScene )
445448
{
446449
QString message( "No read permission on file: " );
447450
message.append( cur.fileName );
448-
QMessageBox::critical( nullptr, "Error", message, 1, 0 );
451+
QMessageBox::critical( nullptr, "Error", message, QMessageBox::Ok );
449452
return;
450453
}
451454
if( m_fileReader->IsMINC1( cur.fileName.toUtf8().data() ) )
@@ -557,7 +560,7 @@ bool Application::GetPointsFromTagFile( QString fileName, PointsObject * pts1, P
557560
{
558561
QString message( "No read permission on file: " );
559562
message.append( fileName );
560-
QMessageBox::critical( nullptr, "Error", message, 1, 0 );
563+
QMessageBox::critical( nullptr, "Error", message, QMessageBox::Ok );
561564
return false;
562565
}
563566
bool ok = m_fileReader->GetPointsDataFromTagFile( fileName, pts1, pts2 );
@@ -1014,7 +1017,7 @@ int Application::GetNumberOfComponents( QString filename )
10141017
{
10151018
QString message( "No read permission on file: " );
10161019
message.append( filename );
1017-
QMessageBox::critical( nullptr, "Error", message, 1, 0 );
1020+
QMessageBox::critical( nullptr, "Error", message, QMessageBox::Ok );
10181021
return false;
10191022
}
10201023
int n = m_fileReader->GetNumberOfComponents( filename );
@@ -1031,7 +1034,7 @@ bool Application::GetGrayFrame( QString filename, IbisItkUnsignedChar3ImageType:
10311034
{
10321035
QString message( "No read permission on file: " );
10331036
message.append( filename );
1034-
QMessageBox::critical( nullptr, "Error", message, 1, 0 );
1037+
QMessageBox::critical( nullptr, "Error", message, QMessageBox::Ok );
10351038
return false;
10361039
}
10371040
bool ok = m_fileReader->GetGrayFrame( filename, itkImage );
@@ -1049,7 +1052,7 @@ bool Application::GetRGBFrame( QString filename, IbisRGBImageType::Pointer itkIm
10491052
{
10501053
QString message( "No read permission on file: " );
10511054
message.append( filename );
1052-
QMessageBox::critical( nullptr, "Error", message, 1, 0 );
1055+
QMessageBox::critical( nullptr, "Error", message, QMessageBox::Ok );
10531056
return false;
10541057
}
10551058
bool ok = m_fileReader->GetRGBFrame( filename, itkImage );

IbisLib/filereader.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void FileReader::SetIbisAPI( IbisAPI * api )
114114
QString mincDir = m_ibisAPI->GetCustomPath( MINCToolsPathVarName );
115115
if( !mincDir.isNull() && !mincDir.isEmpty() )
116116
{
117-
if( mincDir.at( mincDir.count() - 1 ) != '/' ) mincDir.append( "/" );
117+
if( mincDir.at( mincDir.size() - 1 ) != '/' ) mincDir.append( "/" );
118118
m_mincconvert.clear();
119119
m_mincconvert.append( mincDir );
120120
m_mincconvert.append( "mincconvert" );
@@ -183,7 +183,7 @@ bool FileReader::ConvertMINC1toMINC2( QString & inputileName, QString & outputil
183183
tmp.append( inputileName + " is of MINC1 type and needs to be converted to MINC2.\n" +
184184
"Tool mincconvert was not found in standard paths on your file system.\n" +
185185
"Please convert using command: \nmincconvert -2 <input> <output>" );
186-
QMessageBox::critical( 0, "Error", tmp, 1, 0 );
186+
QMessageBox::critical( 0, "Error", tmp, QMessageBox::Ok );
187187
return false;
188188
}
189189
QString dirname( QDir::homePath() );
@@ -247,7 +247,7 @@ bool FileReader::ConvertMINC1toMINC2( QString & inputileName, QString & outputil
247247
QString tmp( "File " );
248248
tmp.append( inputileName + " is an acquired frame of MINC1 type and needs to be converted to MINC2.\n" +
249249
"Tool minccalc was not found in standard paths on your file system.\n" );
250-
QMessageBox::critical( 0, "Error", tmp, 1, 0 );
250+
QMessageBox::critical( 0, "Error", tmp, QMessageBox::Ok );
251251
return false;
252252
}
253253
}
@@ -346,7 +346,7 @@ bool FileReader::OpenFile( QList<SceneObject *> & readObjects, QString filename,
346346
QString tmp( "File " );
347347
tmp.append( filename + " is of MINC1 type and needs to be converted to MINC2.\n" +
348348
"Open Settings/Preferences and set path to the directory containing MINC tools.\n" );
349-
QMessageBox::critical( 0, "Error", tmp, 1, 0 );
349+
QMessageBox::critical( 0, "Error", tmp, QMessageBox::Ok );
350350
return false;
351351
}
352352
if( this->ConvertMINC1toMINC2( filename, fileMINC2, true ) )
@@ -847,7 +847,7 @@ int FileReader::GetNumberOfComponents( QString filename )
847847
QString tmp( "File " );
848848
tmp.append( filename + " is an acquired frame of MINC1 type and needs to be converted to MINC2.\n" +
849849
"Open Settings/Preferences and set path to the directory containing MINC tools.\n" );
850-
QMessageBox::critical( 0, "Error", tmp, 1, 0 );
850+
QMessageBox::critical( 0, "Error", tmp, QMessageBox::Ok );
851851
return 0;
852852
}
853853
if( this->ConvertMINC1toMINC2( filename, fileMINC2, true ) )

0 commit comments

Comments
 (0)