TableModelColumn QML Type
Representa uma coluna em um modelo. Mais...
| Import Statement: | import Qt.labs.qmlmodels |
Descrição detalhada
A classe `TableModelColumn` representa colunas em um ` TableModel`. O ` TableModel ` suporta dados JavaScript/JSON, nos quais cada linha é um objeto, uma lista de pares simples de chave-valor, em que as chaves não são ordenadas.
{
// Each property is one cell/column.
checked: false,
amount: 1,
fruitType: "Apple",
fruitName: "Granny Smith",
fruitPrice: 1.50
},
// ...No entanto, os modelos no Qt são manipulados por meio de índices de linha e coluna. Especificar as colunas com TableModelColumn permite um mapeamento entre as funções integradas do Qt e qualquer propriedade em cada objeto de linha.
import QtQuick
import QtQuick.Window
import Qt.labs.qmlmodels
Window {
width: 400
height: 400
visible: true
TableView {
anchors.fill: parent
columnSpacing: 1
rowSpacing: 1
boundsBehavior: Flickable.StopAtBounds
model: TableModel {
TableModelColumn { display: "checked" }
TableModelColumn { display: "amount" }
TableModelColumn { display: "fruitType" }
TableModelColumn { display: "fruitName" }
TableModelColumn { display: "fruitPrice" }
// Each row is one type of fruit that can be ordered
rows: [
{
// Each property is one cell/column.
checked: false,
amount: 1,
fruitType: "Apple",
fruitName: "Granny Smith",
fruitPrice: 1.50
},
{
checked: true,
amount: 4,
fruitType: "Orange",
fruitName: "Navel",
fruitPrice: 2.50
},
{
checked: false,
amount: 1,
fruitType: "Banana",
fruitName: "Cavendish",
fruitPrice: 3.50
}
]
}
delegate: TextInput {
text: model.display
padding: 12
selectByMouse: true
onAccepted: model.display = text
Rectangle {
anchors.fill: parent
color: "#efefef"
z: -1
}
}
}
}O `TableModelColumn` também oferece suporte básico somente para leitura para linhas complexas. Para mais informações, consulte Supported Row Data Structures.
Observação: A maioria dos conceitos acima também se aplica ao ` TreeModel`, exceto que no ` TreeModel ` cada linha representa um nó da árvore.
Funções suportadas
O TableModelColumn oferece suporte a todas as funções descritas em Qt's roles, com exceção de Qt::InitialSortOrderRole. As funções podem ser acessadas conforme listado abaixo, por exemplo:
text: display
required property string display| Qt::DisplayRole | display |
| Qt::DecorationRole | decoration |
| Qt::EditRole | edit |
| Qt::ToolTipRole | toolTip |
| Qt::StatusTipRole | statusTip |
| Qt::WhatsThisRole | o que é isso |
| Qt::FontRole | fonte |
| Qt::TextAlignmentRole | alinhamento do texto |
| Qt::BackgroundRole | fundo |
| Qt::ForegroundRole | primeiro plano |
| Qt::CheckStateRole | estado_marcado |
| Qt::AccessibleTextRole | texto acessível |
| Qt::AccessibleDescriptionRole | descrição acessível |
| Qt::SizeHintRole | dica de tamanho, nome da função |
Veja também TableModel e TableView.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.