Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmltablemodelcolumn.cpp File Reference

(e23de2b59d189fc52a5ea29b5c2260bfe51c0d6a)

#include "qqmltablemodelcolumn_p.h"
#include <QtQml/qqmlinfo.h>
#include "moc_qqmltablemodelcolumn_p.cpp"
Include dependency graph for qqmltablemodelcolumn.cpp:

Go to the source code of this file.

Macros

#define DEFINE_ROLE_PROPERTIES(getterGetterName, getterSetterName, getterSignal, roleName)

Functions

static QT_BEGIN_NAMESPACE constexpr QLatin1StringView displayRoleName ("display")
 Represents a column in a model.
static constexpr QLatin1StringView decorationRoleName ("decoration")
static constexpr QLatin1StringView editRoleName ("edit")
static constexpr QLatin1StringView toolTipRoleName ("toolTip")
static constexpr QLatin1StringView statusTipRoleName ("statusTip")
static constexpr QLatin1StringView whatsThisRoleName ("whatsThis")
static constexpr QLatin1StringView fontRoleName ("font")
static constexpr QLatin1StringView textAlignmentRoleName ("textAlignment")
static constexpr QLatin1StringView backgroundRoleName ("background")
static constexpr QLatin1StringView foregroundRoleName ("foreground")
static constexpr QLatin1StringView checkStateRoleName ("checkState")
static constexpr QLatin1StringView accessibleTextRoleName ("accessibleText")
static constexpr QLatin1StringView accessibleDescriptionRoleName ("accessibleDescription")
static constexpr QLatin1StringView sizeHintRoleName ("sizeHint")
 DEFINE_ROLE_PROPERTIES (display, setDisplay, displayChanged, displayRoleName) DEFINE_ROLE_PROPERTIES(decoration
decorationRoleName DEFINE_ROLE_PROPERTIES (edit, setEdit, editChanged, editRoleName) DEFINE_ROLE_PROPERTIES(toolTip
decorationRoleName toolTipRoleName DEFINE_ROLE_PROPERTIES (statusTip, setStatusTip, statusTipChanged, statusTipRoleName) DEFINE_ROLE_PROPERTIES(whatsThis
decorationRoleName toolTipRoleName whatsThisRoleName DEFINE_ROLE_PROPERTIES (font, setFont, fontChanged, fontRoleName) DEFINE_ROLE_PROPERTIES(textAlignment
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName DEFINE_ROLE_PROPERTIES (background, setBackground, backgroundChanged, backgroundRoleName) DEFINE_ROLE_PROPERTIES(foreground
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName DEFINE_ROLE_PROPERTIES (checkState, setCheckState, checkStateChanged, checkStateRoleName) DEFINE_ROLE_PROPERTIES(accessibleText
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName accessibleTextRoleName DEFINE_ROLE_PROPERTIES (accessibleDescription, setAccessibleDescription, accessibleDescriptionChanged, accessibleDescriptionRoleName) DEFINE_ROLE_PROPERTIES(sizeHint

Variables

 setDecoration
 decorationChanged
decorationRoleName setToolTip
 [0]
decorationRoleName toolTipChanged
decorationRoleName toolTipRoleName setWhatsThis
decorationRoleName toolTipRoleName whatsThisChanged
decorationRoleName toolTipRoleName whatsThisRoleName setTextAlignment
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentChanged
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName setForeground
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundChanged
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName setAccessibleText
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName accessibleTextChanged
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName accessibleTextRoleName setSizeHint
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName accessibleTextRoleName sizeHintChanged

Macro Definition Documentation

◆ DEFINE_ROLE_PROPERTIES

#define DEFINE_ROLE_PROPERTIES ( getterGetterName,
getterSetterName,
getterSignal,
roleName )
Value:
QJSValue QQmlTableModelColumn::getterGetterName() const \
{ \
return mGetters.value(roleName); \
} \
\
void QQmlTableModelColumn::getterSetterName(const QJSValue &stringOrFunction) \
{ \
if (!stringOrFunction.isString() && !stringOrFunction.isCallable()) { \
qmlWarning(this).quote() << "getter for " << roleName << " must be a function"; \
return; \
} \
if (stringOrFunction.strictlyEquals(decoration())) \
return; \
\
mGetters[roleName] = stringOrFunction; \
}
The QJSValue class acts as a container for Qt/JavaScript data types.
Definition qjsvalue.h:31
#define emit

Definition at line 105 of file qqmltablemodelcolumn.cpp.

Function Documentation

◆ accessibleDescriptionRoleName()

constexpr QLatin1StringView accessibleDescriptionRoleName ( "accessibleDescription" )
staticconstexpr

◆ accessibleTextRoleName()

constexpr QLatin1StringView accessibleTextRoleName ( "accessibleText" )
staticconstexpr

◆ backgroundRoleName()

constexpr QLatin1StringView backgroundRoleName ( "background" )
staticconstexpr

◆ checkStateRoleName()

constexpr QLatin1StringView checkStateRoleName ( "checkState" )
staticconstexpr

◆ decorationRoleName()

constexpr QLatin1StringView decorationRoleName ( "decoration" )
staticconstexpr

◆ DEFINE_ROLE_PROPERTIES() [1/7]

decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName accessibleTextRoleName DEFINE_ROLE_PROPERTIES ( accessibleDescription ,
setAccessibleDescription ,
accessibleDescriptionChanged ,
accessibleDescriptionRoleName  )

◆ DEFINE_ROLE_PROPERTIES() [2/7]

decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName DEFINE_ROLE_PROPERTIES ( background ,
setBackground ,
backgroundChanged ,
backgroundRoleName  )

◆ DEFINE_ROLE_PROPERTIES() [3/7]

decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName DEFINE_ROLE_PROPERTIES ( checkState ,
setCheckState ,
checkStateChanged ,
checkStateRoleName  )

◆ DEFINE_ROLE_PROPERTIES() [4/7]

DEFINE_ROLE_PROPERTIES ( display ,
setDisplay ,
displayChanged ,
displayRoleName  )

◆ DEFINE_ROLE_PROPERTIES() [5/7]

decorationRoleName DEFINE_ROLE_PROPERTIES ( edit ,
setEdit ,
editChanged ,
editRoleName  )

◆ DEFINE_ROLE_PROPERTIES() [6/7]

decorationRoleName toolTipRoleName whatsThisRoleName DEFINE_ROLE_PROPERTIES ( font ,
setFont ,
fontChanged ,
fontRoleName  )

◆ DEFINE_ROLE_PROPERTIES() [7/7]

decorationRoleName toolTipRoleName DEFINE_ROLE_PROPERTIES ( statusTip ,
setStatusTip ,
statusTipChanged ,
statusTipRoleName  )

◆ displayRoleName()

QT_BEGIN_NAMESPACE constexpr QLatin1StringView displayRoleName ( "display" )
staticconstexpr

Represents a column in a model.

\qmltype TableModelColumn

! \nativetype QQmlTableModelColumn \inqmlmodule Qt.labs.qmlmodels

Since
5.14

The TableModelColumn class represents columns in TableModel. TableModel supports JavaScript/JSON data where each row is an object, a list of simple key-value pairs where the keys are unordered.

{
// Each property is one cell/column.
checked: false,
amount: 1,
fruitType: "Apple",
fruitName: "Granny Smith",
fruitPrice: 1.50
},
// ...

However, models in Qt are manipulated via row and column indices. Specifying the columns with TableModelColumn allows a mapping between Qt's built-in roles to any property in each row object.

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]
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
}
]
//![rows]
}
//![delegate]
delegate: TextInput {
text: model.display
padding: 12
selectByMouse: true
onAccepted: model.display = text
Rectangle {
anchors.fill: parent
color: "#efefef"
z: -1
}
}
//![delegate]
}
}

TableModelColumn also has basic read-only support for complex rows. For more information, see \l {Supported Row Data Structures}.

Note
Most of the above concepts also apply to TreeModel, except in TreeModel each row represents a node of the tree.

◆ editRoleName()

constexpr QLatin1StringView editRoleName ( "edit" )
staticconstexpr

◆ fontRoleName()

constexpr QLatin1StringView fontRoleName ( "font" )
staticconstexpr

◆ foregroundRoleName()

constexpr QLatin1StringView foregroundRoleName ( "foreground" )
staticconstexpr

◆ sizeHintRoleName()

constexpr QLatin1StringView sizeHintRoleName ( "sizeHint" )
staticconstexpr

◆ statusTipRoleName()

constexpr QLatin1StringView statusTipRoleName ( "statusTip" )
staticconstexpr

◆ textAlignmentRoleName()

constexpr QLatin1StringView textAlignmentRoleName ( "textAlignment" )
staticconstexpr

◆ toolTipRoleName()

constexpr QLatin1StringView toolTipRoleName ( "toolTip" )
staticconstexpr

◆ whatsThisRoleName()

constexpr QLatin1StringView whatsThisRoleName ( "whatsThis" )
staticconstexpr

Variable Documentation

◆ accessibleTextChanged

◆ decorationChanged

decorationChanged

Definition at line 126 of file qqmltablemodelcolumn.cpp.

◆ foregroundChanged

◆ setAccessibleText

◆ setDecoration

setDecoration

Definition at line 126 of file qqmltablemodelcolumn.cpp.

◆ setForeground

◆ setSizeHint

◆ setTextAlignment

◆ setToolTip

decorationRoleName setToolTip

[0]

Definition at line 130 of file qqmltablemodelcolumn.cpp.

◆ setWhatsThis

Definition at line 134 of file qqmltablemodelcolumn.cpp.

◆ sizeHintChanged

◆ textAlignmentChanged

Definition at line 139 of file qqmltablemodelcolumn.cpp.

◆ toolTipChanged

decorationRoleName toolTipChanged

Definition at line 130 of file qqmltablemodelcolumn.cpp.

◆ whatsThisChanged

Definition at line 134 of file qqmltablemodelcolumn.cpp.