0

I'm trying to run the imageviewer example from this website https://doc.qt.io/qt-5/qtwidgets-widgets-imageviewer-example.html. However, for some reason I don't seem to have QColorSpace. I tried to include all of the possible libraries I thinnk I would need but still have no luck. Is it my CMake file or do I need to somehow install QColorSpace?

cmake_minimum_required(VERSION 3.5)

project(SAT_Solver LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# QtCreator supports the following variables for Android, which are identical to qmake Android variables.
# Check http://doc.qt.io/qt-5/deployment-android.html for more information.
# They need to be set before the find_package(Qt5 ...) call.

#if(ANDROID)
#    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
#    if (ANDROID_ABI STREQUAL "armeabi-v7a")
#        set(ANDROID_EXTRA_LIBS
#            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so
#            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so)
#    endif()
#endif()

find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets PrintSupport OpenGL Core Gui REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets PrintSupport OpenGL Core Gui REQUIRED)

if(ANDROID)
  add_library(SAT_Solver SHARED
    main.cpp
    mainwindow.cpp
    mainwindow.h
    mainwindow.ui
    ScribbleArea.cpp
    ScribbleArea.h
  )
else()
  add_executable(SAT_Solver
    main.cpp
    mainwindow.cpp
    mainwindow.h
    mainwindow.ui
    ScribbleArea.cpp
    ScribbleArea.h
    imageviewer.h
    imageviewer.cpp
  )
endif()
#qt5_add_resources(RC_SRC "resources/qml.qrc")
#qt5_add_resources(RC_SRC "/home/nalfredo/School/AutoSoftware/Project/QT/SAT_Solver/Resources.qrc")


target_link_libraries(SAT_Solver PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport
    ${QT_QTSVG_LIBRARY} Qt${QT_VERSION_MAJOR}::OpenGL Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Core Qt5::Gui)
  • 2
    [QColorSpace](https://doc.qt.io/qt-5/qcolorspace.html) _was introduced in Qt 5.14._ So, you need a quite recent version of Qt for this. (Current release is 5.15.1.) Which one did you install on your side? – Scheff's Cat Oct 31 '20 at 06:39
  • 2
    The sample seems to be made (or updated) quite recently as well. It's the first time I see a CMake build script which is already prepared for Qt6... :-) – Scheff's Cat Oct 31 '20 at 06:44
  • How do I check my version on Qt Creator? – Alfredo Velasco Oct 31 '20 at 07:00
  • I'm not sure. The simplest way which comes in mind: Write a minimal program which does `qDebug() << "Qt Version:" << QT_VERSION_STR;` in `main()` (like e.g. [here](https://stackoverflow.com/a/64611396/7478597)). – Scheff's Cat Oct 31 '20 at 07:03
  • 1
    ...or google. I found [SO: How to find Version of Qt?](https://stackoverflow.com/a/40112592/7478597) :-) – Scheff's Cat Oct 31 '20 at 07:05
  • 1
    qmake --version returned Qt 5.9.5. I guess I need to update. Thanks for the help – Alfredo Velasco Oct 31 '20 at 07:15
  • 1
    Does this answer your question? [How to find Version of Qt?](https://stackoverflow.com/questions/23058718/how-to-find-version-of-qt) – Scheff's Cat Oct 31 '20 at 07:17
  • No. I followed the steps but the minimal program still says I'm running Qt 5.9.5 even after I installed Qt 5.15.1. – Alfredo Velasco Oct 31 '20 at 07:43
  • I now have Qt 5.15.1 running after purging my old Qt files. Now my code doesn't work for different reasons. Thanks for all of your help – Alfredo Velasco Oct 31 '20 at 07:53

0 Answers0