Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Dynamic Scene exampe as CMake
Forum Updated to NodeBB v4.3 + New Features

Dynamic Scene exampe as CMake

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 139 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Marc Haubenstock
    wrote on last edited by
    #1

    I am trying to run the DynamicScene example project as a Cmake based project in CLion.
    However I am having problems accessing the conent folder which holds all of the assets.

    The project builds fine, but at runtime the qml file can not resolve the

    import "content" 
    

    statement

    My main.cpp looks like this

        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
    
        const QUrl url(QStringLiteral("qrc:/dynamicscene.qml"));
        QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                         &app, [url](QObject *obj, const QUrl &objUrl) {
                    if (!obj && url == objUrl)
                        QCoreApplication::exit(-1);
                }, Qt::QueuedConnection);
        engine.load(url);
    
        return QGuiApplication::exec();
    

    Which is the standard cpp main from the creator.

    My Cmake file looks like this:

    cmake_minimum_required(VERSION 3.5)
    
    project(Scroll)
    
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    #set(CMAKE_INCLUDE_CURRENT_DIR ON)
    set(Qt5_DIR "~/Code/Cpp/Qt/5.14.0/gcc_64/lib/cmake/Qt5")
    
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    
    
    find_package(Qt5 COMPONENTS Core Quick REQUIRED)
    
    add_executable(Scroll
      Scroll/main.cpp
      Scroll/qml.qrc
    )
    target_compile_definitions(Scroll
      PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
    target_link_libraries(Scroll
      PRIVATE Qt5::Core Qt5::Quick)
    
    
    add_executable(DynamicScene
            DynamicScene/main.cpp
            DynamicScene/qml.qrc
            )
    target_compile_definitions(DynamicScene
            PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
    target_link_libraries(DynamicScene
            PRIVATE Qt5::Core Qt5::Quick)
    

    The scoll project is another example which works fine.

    How can I make the content folder visible to cmake/clion project?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved