1. 代码
ListModel {
id: libraryModel
ListElement {
title: "A Masterpiece"
author: "Gabriel"
}
ListElement {
title: "Brilliance"
author: "Jens"
}
ListElement {
title: "Outstanding"
author: "Frederik"
}
}
TableView {
width: 640
height: 480
sortIndicatorVisible: true //已开启,但是不显示
TableViewColumn {
role: "title"
title: "Title"
width: 100
}
TableViewColumn {
role: "author"
title: "Author"
width: 200
}
model: libraryModel
}
2. 解决方法
main.cpp
中将QGuiApplication app(argc, argv);
改为QApplication app(argc, argv);