PR merged https://github.com/texstudio-org/texstudio/pull/4394.patch
see https://bugs.gentoo.org/940747
check Qt${QT_VERSION_MAJOR} at first to respect an exported value of QT_VERSION_MAJOR
and avoid conflict if both Qt5/Qt6 are installed
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -57,7 +57,11 @@ if(WIN32 AND NOT MSVC)
         #add_compile_options(-Wa,-mbig-obj)
 endif()
 
-find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets LinguistTools REQUIRED)
+if(QT_VERSION_MAJOR)
+    find_package(QT NAMES Qt${QT_VERSION_MAJOR} COMPONENTS Widgets LinguistTools REQUIRED)
+else()
+    find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets LinguistTools REQUIRED)
+endif()
 find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Network Xml Concurrent Widgets UiTools REQUIRED)
 find_package(Qt${QT_VERSION_MAJOR} COMPONENTS PrintSupport Svg Qml REQUIRED)
 if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
