Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Custom QML Component: Put children into Rowlayout
Forum Updated to NodeBB v4.3 + New Features

Custom QML Component: Put children into Rowlayout

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 550 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maxwell31
    wrote on last edited by
    #1

    Hi,

    I am working on a Toolbar with sections. Depending on context, the sections should be visible or not. I am wondering, if I can make the plotSection Item a component, which I could reuse for other sections. Here is my current code:

    import QtQuick 2.10
    import QtQuick.Controls 2.13
    import QtQuick.Layouts 1.12
    import Style 1.0
    
    ToolBar {
        id: mainToolBar
        objectName: "mainToolBar"
    
        RowLayout {
            Item {
                id: plotSection
                width: bRow.implicitWidth
                implicitHeight: bRow.implicitHeight+15+Style.marginTiny
                Row {
                    id: bRow
                    ToolButton {
                        text: "Save plot"
                        icon.source: "../icons/file-export-solid.svg"
                        onClicked: {
                            savePlot()
                        }
                    }
                    ToolButton {
                        id: showfullrange
                        text: "Zoom to data range"
                        icon.source: "../icons/full_screen_2.svg"
                        icon.width: 24
                        icon.height: 24
                        onClicked: {
                            plotCpp.resetViewFullRange()
                        }
                    }
                    ToolButton {
                        id: resetview
                        text: "Zoom to standard range"
                        icon.source: "../icons/full_screen.svg"
                        icon.width: 24
                        icon.height: 24
                        onClicked: {
                            plotCpp.resetView()
                        }
                    }
                }
                SectionLabel {
                    anchors {bottom: parent.bottom; right: parent.right; left: parent.left; bottomMargin: Style.marginTiny}
                    text: "Plot"
                }
            }
        }
    }
    

    IIdeally, I would like to use it like this:

    ToolbarSection {
        label: "Plots"
        ToolButton {
                        text: "Save plot"
                        icon.source: "../icons/file-export-solid.svg"
                        onClicked: {
                            savePlot()
                        }
                    }
                    ToolButton {
                        id: showfullrange
                        text: "Zoom to data range"
                        icon.source: "../icons/full_screen_2.svg"
                        icon.width: 24
                        icon.height: 24
                        onClicked: {
                            plotCpp.resetViewFullRange()
                        }
                    }
                    ToolButton {
                        id: resetview
                        text: "Zoom to standard range"
                        icon.source: "../icons/full_screen.svg"
                        icon.width: 24
                        icon.height: 24
                        onClicked: {
                            plotCpp.resetView()
                        }
                    }
    }
    

    However, I would not know how to give the children of this ToolbarSection to be inside the Row of the ToolBarSection component. Is this even possible?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maxwell31
      wrote on last edited by
      #2

      This is what I have been looking for:
      https://together.jolla.com/question/4717/how-to-position-nested-items-in-a-qml-component/

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved