BlinCT
BlinCTSept. 15, 2023, 12:35 p.m.

Размеры полей в TreeView

qml

Всем привет.
Пытаюсь сделать дерево вот такого вида

Дерево treeview
Пытаюсь организовать делегат для каждой строки в дереве. ТО есть отступ какого то размера и если при открытии есть подсписок то увеличивать наверное с каждым шагом по 2.
Но что-то не моуг правильно выстроить данные для строки.
Может кто поправить меня где ошибка у меня?
Вот часть кода:

Rectangle
        {
            SplitView.minimumWidth: root.width * 0.1
//            SplitView.maximumWidth: root.width * 0.25

            width: root.width * 0.5

            color: "#5a5a5a" // TODO: need from C++

            TreeView
            {
                id: treeViewBookmark

                anchors.fill: parent

                clip: true

                delegate: Item
                {
                    id: treeDelegate
                    required property int page
                    required property point location
                    required property real zoom
//                    color: "yellow"

//                    implicitWidth: padding + label.x + label.implicitWidth + padding
                    implicitHeight: label.implicitHeight * 1.5

                    readonly property real indent: 20
                    readonly property real padding: 5

//                    // Assigned to by TreeView:
                    required property TreeView treeView
                    required property bool isTreeNode
                    required property bool expanded
                    required property int hasChildren
                    required property int depth

                    RowLayout
                    {
                        spacing: treeViewBookmark.width * 0.03

                        anchors.fill: parent

                        Rectangle
                        {
                            id: name

                            Layout.fillHeight: true
                            width: treeDelegate.padding + (treeDelegate.depth * indicator.width)
                            color: "yellow"
//                            Layout.width: treeDelegate.padding + (treeDelegate.depth * treeDelegate.indent)
                        }

                        Rectangle
                        {
                            id: rectIndicator

                            width: childrenRect.width

                            Text
                            {
                                id: indicator
                                visible: treeDelegate.isTreeNode && treeDelegate.hasChildren
//                                x: padding + (treeDelegate.depth * treeDelegate.indent)
                                anchors.verticalCenter: label.verticalCenter
                                text: "▸"
                                rotation: treeDelegate.expanded ? 90 : 0
                            }
                        }

                        Rectangle
                        {
                            id: rectTabel

                            Text
                            {
                                id: label
                                anchors.fill: parent

                                clip: true
                                text: model.display
                                color: "#b7b7b7"
                            }
                        }


                    }

                    TapHandler {
                        onTapped: {
                            treeView.toggleExpanded(row)
                            var qi = treeViewBookmark.index(row, 0)
                        }
                    }
                }

                model: PdfBookmarkModel
                {
                    document: docPdf
                }

                ScrollBar.vertical: ScrollBar { }
            }
        }

Заранее благодарю

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.

Do you like it? Share on social networks!

0

Comments

Only authorized users can post comments.
Please, Log in or Sign up
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:80points,
  • Rating points4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:20points,
  • Rating points-10

C++ - Тест 003. Условия и циклы

  • Result:42points,
  • Rating points-8
Last comments
A
ALO1ZEOct. 19, 2024, 6:19 p.m.
Fb3 file reader on Qt Creator Подскажите как это запустить? Я не шарю в программировании и кодинге. Скачал и установаил Qt, но куча ошибок выдается и не запустить. А очень надо fb3 переконвертировать в html
ИМ
Игорь МаксимовOct. 5, 2024, 5:51 p.m.
Django - Lesson 064. How to write a Python Markdown extension Приветствую Евгений! У меня вопрос. Можно ли вставлять свои классы в разметку редактора markdown? Допустим имея стандартную разметку: <ul> <li></li> <li></l…
d
dblas5July 5, 2024, 9:02 p.m.
QML - Lesson 016. SQLite database and the working with it in QML Qt Здравствуйте, возникает такая проблема (я новичок): ApplicationWindow неизвестный элемент. (М300) для TextField и Button аналогично. Могу предположить, что из-за более новой верси…
k
kmssrFeb. 9, 2024, 5:43 a.m.
Qt Linux - Lesson 001. Autorun Qt application under Linux как сделать автозапуск для флэтпака, который не даёт создавать файлы в ~/.config - вот это вопрос ))
Qt WinAPI - Lesson 007. Working with ICMP Ping in Qt Без строки #include <QRegularExpressionValidator> в заголовочном файле не работает валидатор.
Now discuss on the forum
9
9AnonimOct. 25, 2024, 7:10 p.m.
Машина тьюринга // Начальное состояние 0 0, ,<,1 // Переход в состояние 1 при пустом символе 0,0,>,0 // Остаемся в состоянии 0, двигаясь вправо при встрече 0 0,1,>…
J
JacobFibOct. 17, 2024, 1:27 p.m.
добавить qlineseries в функции Пользователь может получить любые разъяснения по интересующим вопросам, касающимся обработки его персональных данных, обратившись к Оператору с помощью электронной почты https://topdecorpro.ru…
JW
Jhon WickOct. 2, 2024, 1:52 a.m.
Indian Food Restaurant In Columbus OH| Layla’s Kitchen Indian Restaurant If you're looking for a truly authentic https://www.laylaskitchenrestaurantohio.com/ , Layla’s Kitchen Indian Restaurant is your go-to destination. Located at 6152 Cleveland Ave, Colu…
КГ
Кирилл ГусаревSept. 27, 2024, 7:09 p.m.
Не запускается программа на Qt: точка входа в процедуру не найдена в библиотеке DLL Написал программу на C++ Qt в Qt Creator, сбилдил Release с помощью MinGW 64-bit, бинарнику напихал dll-ки с помощью windeployqt.exe. При попытке запуска моей сбилженной программы выдаёт три оши…

Follow us in social networks