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. Problem with Build in QML
Forum Updated to NodeBB v4.3 + New Features

Problem with Build in QML

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 40 Views 1 Watching
  • 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.
  • B Offline
    B Offline
    Blackzero
    wrote last edited by
    #1

    I was previously a Qt Widget user and just tried using QML Quick for the first time but immediately encountered this problem, how do I solve it?
    Screenshot 2025-06-29 011049.png

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ankou29666
      wrote last edited by
      #2

      CMake project configuration failed ?
      could you please show us your CMakeLists.txt file ?

      B 1 Reply Last reply
      0
      • A ankou29666

        CMake project configuration failed ?
        could you please show us your CMakeLists.txt file ?

        B Offline
        B Offline
        Blackzero
        wrote last edited by
        #3

        @ankou29666 of course

        cmake_minimum_required(VERSION 3.16)
        
        project(untitled VERSION 0.1 LANGUAGES CXX)
        
        set(CMAKE_CXX_STANDARD_REQUIRED ON)
        
        find_package(Qt6 REQUIRED COMPONENTS Quick)
        
        qt_standard_project_setup(REQUIRES 6.8)
        
        qt_add_executable(appuntitled
            main.cpp
        )
        
        qt_add_qml_module(appuntitled
            URI untitled
            VERSION 1.0
            QML_FILES
                Main.qml
        )
        
        # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
        # If you are developing for iOS or macOS you should consider setting an
        # explicit, fixed bundle identifier manually though.
        set_target_properties(appuntitled PROPERTIES
        #    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appuntitled
            MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
            MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
            MACOSX_BUNDLE TRUE
            WIN32_EXECUTABLE TRUE
        )
        
        target_link_libraries(appuntitled
            PRIVATE Qt6::Quick
        )
        
        include(GNUInstallDirs)
        install(TARGETS appuntitled
            BUNDLE DESTINATION .
            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
            RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
        )
        
        
        1 Reply Last reply
        0
        • A Offline
          A Offline
          ankou29666
          wrote last edited by
          #4

          I don't remember what is the error message displayed in that case but all I notice is that you define a target name but next define properties for another target name.

          either you rename your project to appuntitled, or you rename it untitled everywhere else. But mixing "untitled" in project definition with "appuntitled" everywhere else won't work for sure.

          Best practice is to use ${PROJECT_NAME} variable :

          project (somename blablabla)
          qt_add_executable (${PROJECT_NAME} yourfiles)
          qt_add_qml_module (${PROJECT_NAME}
              URI your.project.uri
              RESOURCE_PREFIX someprefix
              VERSION 1.0
              QML_FILES
                 YourQmlFiles.qml
          )
          

          it's more reliable template than QtCreator's defaults.

          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