daguerreo / qmltreeview Goto Github PK
View Code? Open in Web Editor NEWA TreeView component for QML/QtQuick 2 with a generic TreeModel for Qt5 and compatible with Qt6
License: MIT License
A TreeView component for QML/QtQuick 2 with a generic TreeModel for Qt5 and compatible with Qt6
License: MIT License
font
propertyrowHeight
property to allow to change row size modifying selection item and hover item without reimplement the delegaterowPadding
: how much space a child node is shifted from the parentrowSpacing
: distance between indicator and contentItem
When adds the first new item here
// main.cpp
void populateModel(TreeModel& model)
{
auto america = new TreeItem("America");
auto asia = new TreeItem("Asia");
auto europe = new TreeItem("Europe");
auto oceania = new TreeItem("Oceania");
auto brazil = new TreeItem("Brazil");
auto canada = new TreeItem("Canada");
auto mexico = new TreeItem("Mexico");
auto usa = new TreeItem("USA");
auto italy = new TreeItem("Italy");
auto france = new TreeItem("France");
auto portugal = new TreeItem("Portugal");
auto spain = new TreeItem("Spain");
model.addTopLevelItem(america); // <--- assertion failed here
...
an assertion failure will be triggered due to parent.childrenCount() - 1 == -1
// tree_model.h
void TreeModel::addItem(TreeItem* parent, TreeItem* child) {
if (!child || !parent) {
return;
}
emit layoutAboutToBeChanged();
if (child->parentItem()) {
beginRemoveRows(QModelIndex(), child->parentItem()->childCount() - 1, child->parentItem()->childCount());
child->parentItem()->removeChild(child);
endRemoveRows();
}
beginInsertRows(QModelIndex(), parent->childCount() - 1, parent->childCount() - 1); // bug
child->setParentItem(parent);
parent->appendChild(child);
endInsertRows();
emit layoutChanged();
}
Add unit tests for the TreeModel
Hi
I added a proxy model to filter the data, but there is actually no filtering.
Do I need to force update the data by sending a signal to the view?
TreeModel supports only the DisplayMode role. Implement the support for the other roles, standard and custom. Could be nice adding an example using different roles.
Build the tree from the TreeItem
, than set directly the root item with a dedicated method
and make the examples load the plugin
All the examples have these warnings in Qt6 but not in Qt5
qrc:/modules/QMLTreeView/TreeView.qml:83:5: QML TreeViewItem: Binding loop detected for property "handleColor"
qrc:/modules/QMLTreeView/TreeView.qml:83:5: QML TreeViewItem: Binding loop detected for property "selectedItemColor"
qrc:/modules/QMLTreeView/TreeViewItem.qml:108:4: QML ColumnLayout: Qt Quick Layouts: Polish loop detected. Aborting after two iterations.
Hi,
How to clear the model of the tree?
I called the clear() function but it didn't work.
Add basic tree manipulation:
Make delegate for highlighting an external component like the highlight
property of ListView
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.