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. Layout depending on loaded component
Forum Updated to NodeBB v4.3 + New Features

Layout depending on loaded component

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 329 Views 1 Watching
  • 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    I have a TableView, and use a Button as delegate in one column.
    Now the row height of the TableView should be at least the height of the Button (depending on font, etc.)
    I need to set a property on the button delegate, and the only way I found how to do this was via Loader.

    Code of Delegate in file lpad_buttondelegate.qml (part of resources)

    Item
    {
        anchors.fill: parent
        property Component thedelegate: actionButton
        Button
        {
            id: actionButton
            anchors.centerIn: parent
            width: parent.width * 0.9
            text: buttonText
        }
    }
    

    Use of delegate in TableViewColumn:

            TableViewColumn
            {
                id: startButtonColumn
                title: Cpp.CLpad_Mls.getText("LPAD_COLUMN_START");
                movable: false
                resizable: false
                width: tableView.width * 0.15
                delegate: Loader
                {
                    property string buttonText: "Start"
                    source: "lpad_buttondelegate.qml"
                }
            }
    

    Now I need to adjust the row height. Seems the rowDelegate is the way to go:

           rowDelegate: Rectangle
           {
              height: 30
              // Question: How to use height of button delegate?
              SystemPalette
              {
                 id: myPalette;
                 colorGroup: SystemPalette.Active
              }
              color:
              {
                 var baseColor = styleData.alternate?myPalette.alternateBase:myPalette.base
                 return styleData.selected?myPalette.highlight:baseColor
              }
           }
    

    At the moment, I have the row delegate a fixed height. But I would like to set a minimumHeight to the height of the button delegate.
    But how do I do that? I suppose, if I use Loader, I will have a fat button sitting in my rowDelegate. That's not what I need - I'd just like to 'peek' the height the button delegate has, so I can adjust the row height accordingly.

    Any ideas how to do this?

    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