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 Solved General and Desktop
8 Posts 2 Posters 77 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
    • B Offline
      B Offline
      Blackzero
      wrote last edited by
      #7

      Problem solved.
      I think this is a bug in Qt 6.8.2, after I use Qt 6.9.1 there is no this error.

      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.

            B 2 Replies Last reply
            0
            • A ankou29666

              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.

              B Offline
              B Offline
              Blackzero
              wrote last edited by
              #5

              @ankou29666 said in Problem with Build in QML:

              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.

              I didn't know that, cmake is automatically generated by Qt Creator. I will try it.

              1 Reply Last reply
              0
              • A ankou29666

                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.

                B Offline
                B Offline
                Blackzero
                wrote last edited by
                #6

                @ankou29666
                here are the error details
                Screenshot 2025-06-29 140018.png

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  Blackzero
                  wrote last edited by
                  #7

                  Problem solved.
                  I think this is a bug in Qt 6.8.2, after I use Qt 6.9.1 there is no this error.

                  1 Reply Last reply
                  0
                  • B Blackzero has marked this topic as solved
                  • A Offline
                    A Offline
                    ankou29666
                    wrote last edited by
                    #8

                    made a try with 6.8.3 on mac, the default template makes project untitled and everywhere else is appuntitled. builds fine, fine. (just complaining that virtual keyboard is not installed, I don't really understand why but doesn't matter). So yeah looks like the name given in project doesn't have to match the name given in qt_add_executable.

                    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