hcaslan
hcaslan

Reputation: 31

TableViewColumn is not a type

I get an error when trying to create a table.

I realised this when I needed a table in the code I wrote. Everything works without error, except TableViewColumn. I tried separating it from the other code to try to create a table, but I could not understand the problem.

Main.qml:

import QtQuick 2.15
import QtQuick.Controls 2.15

TableView {
    id: tableView
    width: 400
    height: 300

    TableViewColumn {
        role: "name"
        title: "Name"
        width: 200
    }

    TableViewColumn {
        role: "age"
        title: "Age"
        width: 100
    }

    model: ListModel {
        ListElement { name: "Alice"; age: 30 }
        ListElement { name: "Bob"; age: 25 }
    }
}

CmakeLists.txt:

cmake_minimum_required(VERSION 3.16)

project(qt_test_projesi VERSION 0.1 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
find_package(Qt6 REQUIRED COMPONENTS Quick QuickControls2)

qt_standard_project_setup(REQUIRES 6.5)

qt_add_executable(appqt_test_projesi
    main.cpp
)

qt_add_qml_module(appqt_test_projesi
    URI qt_test_projesi
    VERSION 1.0
    QML_FILES
        Main.qml
)

set_target_properties(appqt_test_projesi PROPERTIES
    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(appqt_test_projesi PRIVATE Qt6::Quick Qt6::QuickControls2)

include(GNUInstallDirs)
install(TARGETS appqt_test_projesi
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

Upvotes: 1

Views: 36

Answers (0)

Related Questions