c++ - 如何使整个 GridView 行垂直展开

标签 c++ qt qml

所以我想做的是通过单击鼠标展开单个 GridView 行。它看起来应该有点类似于 this .想象一下,在鼠标单击之前,行之间的距离相等,然后行垂直展开,当菜单关闭时,行又恢复到正常间距。

使用标准 GridView 是否可行,还是我必须创建自己的?我试过 cellHeight,但这会改变每一行的高度,而不仅仅是当前行的高度。

最佳答案

如果您不使用 GridView 而是使用包含三行的列,可能会更容易。您可以在不需要时简单地使中间行不可见。这将使 UI 更加灵活。

这应该是这样的:

property bool informationsVisible: false
Column {
    anchors.fill: parent
    Row {
        id: firstRow
        Repeater {
            model: firstHalfOfYourData
            delegate: MouseArea {
                //Your item representation
            }
        }
    }

    Row {
        id: informationsRow
        visible: informationsVisible
            //Display informations on the selected element here
    }

    Row {
        id: secondRow
        Repeater {
            model: secondHalfOfYouData
            delegate: MouseArea {
                //Your item representation
            }
        }
    }
}

关于c++ - 如何使整个 GridView 行垂直展开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23146744/

相关文章:

c++ - 模板类指针 c++ 声明

c++ - 使用 QuaZip 在 Mac 上提取 .app

c++ - QML listview读取当前和触摸区域

c++ - Horizo​​ntalHeaderView 不调用 QAbstractTableModel 的 child 的 headerData()

qt - 如何确定当前项目是否是 ListView 部分中的最后一项

c++ - 如何将子目录库与 QMake 链接起来?

c++ - 涉及链表和指针的结构

c++ - 如何将std::find()与2d std:数组一起使用?

Qt 小部件 setStyleSheet

c++ - 在 Qt 中获取系统用户名