File tree Expand file tree Collapse file tree 3 files changed +43
-18
lines changed
Expand file tree Collapse file tree 3 files changed +43
-18
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ project(NodeEditor CXX)
44
55set (CMAKE_DISABLE_IN_SOURCE_BUILD ON )
66set (CMAKE_DISABLE_SOURCE_CHANGES ON )
7+ set (OpenGL_GL_PREFERENCE LEGACY)
78
89get_directory_property (_has_parent PARENT_DIRECTORY )
910if (_has_parent)
@@ -37,14 +38,28 @@ endif()
3738
3839add_subdirectory (external)
3940
41+
4042# Find the QtWidgets library
41- find_package (Qt5 5.3 COMPONENTS
42- Core
43- Widgets
44- Gui
45- OpenGL)
43+ find_package (Qt6
44+ REQUIRED COMPONENTS
45+ Core
46+ Widgets
47+ Gui
48+ OpenGL
49+ )
50+
51+ if (NOT Qt6_FOUND)
52+ find_package (Qt5 5.15
53+ REQUIRED COMPONENTS
54+ Core
55+ Widgets
56+ Gui
57+ OpenGL
58+ )
59+ endif ()
60+
4661
47- qt5_add_resources (RESOURCES ./resources/resources.qrc)
62+ qt_add_resources (RESOURCES ./resources/resources.qrc)
4863
4964# Unfortunately, as we have a split include/src, AUTOMOC doesn't work.
5065# We'll have to manually specify some files
@@ -93,15 +108,14 @@ target_include_directories(nodes
93108
94109target_link_libraries (nodes
95110 PUBLIC
96- Qt5 ::Core
97- Qt5 ::Widgets
98- Qt5 ::Gui
99- Qt5 ::OpenGL
111+ Qt ::Core
112+ Qt ::Widgets
113+ Qt ::Gui
114+ Qt ::OpenGL
100115)
101116
102117target_compile_definitions (nodes
103118 PUBLIC
104- ${Qt5Widgets_DEFINITIONS}
105119 NODE_EDITOR_SHARED
106120 PRIVATE
107121 NODE_EDITOR_EXPORTS
@@ -131,7 +145,7 @@ set_target_properties(nodes
131145
132146file (GLOB_RECURSE HEADERS_TO_MOC include /nodes/internal /*.hpp)
133147
134- qt5_wrap_cpp (nodes_moc
148+ qt_wrap_cpp (nodes_moc
135149 ${HEADERS_TO_MOC}
136150 TARGET nodes
137151 OPTIONS --no -notes # Don't display a note for the headers which don't produce a moc_*.cpp
Original file line number Diff line number Diff line change 11#include " NodeGeometry.hpp"
22
3- #include < iostream>
4- #include < cmath>
5-
63#include " PortType.hpp"
74#include " NodeState.hpp"
85#include " NodeDataModel.hpp"
96#include " Node.hpp"
107#include " NodeGraphicsObject.hpp"
11-
128#include " StyleCollection.hpp"
139
10+ #include < QtGlobal>
11+
12+ #include < iostream>
13+ #include < cmath>
14+
1415using QtNodes::NodeGeometry;
1516using QtNodes::NodeDataModel;
1617using QtNodes::PortIndex;
@@ -356,8 +357,13 @@ portWidth(PortType portType) const
356357 name = _dataModel->dataType (portType, i).name ;
357358 }
358359
360+ #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
361+ width = std::max (unsigned (_fontMetrics.horizontalAdvance (name)),
362+ width);
363+ #else
359364 width = std::max (unsigned (_fontMetrics.width (name)),
360365 width);
366+ #endif
361367 }
362368
363369 return width;
Original file line number Diff line number Diff line change 11find_package (Catch2 2.3.0 REQUIRED)
2- find_package (Qt5 COMPONENTS Test )
2+
3+ if (Qt6_FOUND)
4+ find_package (Qt6 COMPONENTS Test )
5+ else ()
6+ find_package (Qt5 COMPONENTS Test )
7+ endif ()
38
49add_executable (test_nodes
510 test_main.cpp
@@ -20,7 +25,7 @@ target_link_libraries(test_nodes
2025 PRIVATE
2126 NodeEditor::nodes
2227 Catch2::Catch2
23- Qt5 ::Test
28+ Qt ::Test
2429)
2530
2631add_test (
You can’t perform that action at this time.
0 commit comments