Giter Club home page Giter Club logo

qtquickcontrols2.treeview's Introduction

QtQuickControls2.TreeView

Build Status

This repository contains the sources for a QtQuickControls2 based TreeView control that you can use in your qml desktop application.

State

This user control is in alpha version. There are some missing features or things that do not work yet:

  • dynamic insertion works by appending items, order is not correct at the moment
  • dynamic removal does not work
  • there is no selection model
  • root index cannot be set

Why this project?

QtQuickControls2 do not provide a TreeView control yet because they focus on mobile application development where tree view are not that common. But QtQuickControls2 can also be used to develop nice desktop applications and a tree view component is often needed. I needed a TreeView for one of my personal (but still private) project so I decided to create a one myself.

Solution

The solution I found is to use a ListView Item as the base qml item of the tree view and use a proxy model that flatten a source tree model.

Source code organisation

  • The core of the library can be found in the lib folder. This is a header only library that contains the TreeViewModel and the TreeItemViewModel

  • The imports directory contains the qml implementation of the TreeView and the TreeItemView. The TreeItemView delegate is extensible: you can specify the component to use to to render both the arrow and the display items. It handles indentation and expanding/collapsing of nodes automatically for you.

  • There is also a small tests suite (using the catch testing framework ) that you can run using ctest.

  • The example create two tree model: a StandardItemModel and QFileSystemModel. It then wraps those two models in a TreeViewModel and exposes them via a context property.

How can I use it ?

License here is "super-open", not even copy-left or copy-right, just use it as you want, as it's the most practical to you:

  • if you want to use it as GIT submodule and compile it in your app, do it!
  • if you prefer separate project as a shared library, do it!
  • if you need to modify the project to be able to integrate in you app (opensource or not), do it!
  • if you want to share your work on the library, thanks a lot, but if you don't, no problem!

qtquickcontrols2.treeview's People

Contributors

colinduquesnoy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

qtquickcontrols2.treeview's Issues

Why doesn't the QQuickWidget program display when using QQmlApplicationEngine replacement?

I modify the program support QT5.8.

` QQucikWidget* pWidget = new QQucikWidget();
pWidget->setResizeMode(QuickWidget:SizeRootObjectToView);

QStandardItemModel standardItemModel;
QStandardItem root("Root");
root.setIcon(qtApp.style()->standardIcon(QStyle::SP_DesktopIcon));
QStandardItem child1("Child 1");
QStandardItem child2("Child 2");
QStandardItem child3("Child 3");
QStandardItem child1OfChild1("Child 1 of Child 1");
QStandardItem child2OfChild1("Child 2 of Child 1");
QStandardItem child1OfChild2("Child 1 of Child 2");

child1.appendRow(&child1OfChild1);
child1.appendRow(&child2OfChild1);
child2.appendRow(&child1OfChild2);
root.appendRow(&child1);
root.appendRow(&child2);
root.appendRow(&child3);
standardItemModel.appendRow(&root);

TreeViewModel standardItemTreeViewModel;
standardItemTreeViewModel.setSourceModel(&standardItemModel);

pWidget ->rootContext()->setContextProperty("standardItemModel", &standardItemTreeViewModel);

 pWidget ->load(QUrl("qrc:/main.qml"));`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.