Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access data in QML TableViewColumn delegate?

Tags:

qt

qml

qt5.1

How to access the current item in a TableViewColumn?

TableView {
    id: atcTableView
    model: myatclist
    ...
    TableViewColumn {
        ...
    }
    TableViewColumn {
        id: atcTableViewColFreq
        role: "frequency"
        title: "Frequency"
        width: 120
        delegate: Component {
            Text {
                text: "Freq is " + currentItem / model / model.frequency
            }
        }
    }

As of this similar question " How do you access the roles of the currentItem from a listview in QML? " I have tried all kind of combinations model, modelData , currentItem, and something like model.role.

If I remove the delegate entirely, frequency displays correctly. Model is based on QAbstractListModel. Any hints?

Btw, can I see in QML debugging what properties are available in a delegate?

-- Edit based on Kakadu's comment --

        delegate {
            Text {
                text: "freq is " + frequency
            }
        }

gives me: ReferenceError: frequency is not defined

like image 811
Horst Walter Avatar asked Dec 09 '22 11:12

Horst Walter


1 Answers

delegate: Text { text: view.model.get(styleData.row).frequency }
like image 53
Sohail Avatar answered Dec 11 '22 10:12

Sohail