本页内容

GridMesh QML Type

定义一个顶点按网格排列的网格。更多...

Import Statement: import QtQuick

属性

详细说明

GridMesh 定义了一个由均匀分布在网格上的顶点组成的矩形网格。它用于生成geometry 。网格分辨率通过resolution 属性指定。

属性文档

resolution : size

该属性用于指定网格分辨率。分辨率的宽度和高度分别指定水平方向和垂直方向上顶点之间的单元格数量或间距。最小值和默认值均为 1x1,这对应于总共四个顶点,每个角落各有一个。对于非线性顶点变换,您可能需要将分辨率设置得更高。

结果QML 代码gridmesh.vert

Qt 徽标因 GridMesh 变换而变形

import QtQuick 2.0

ShaderEffect {
    width: 200
    height: 200
    mesh: GridMesh {
        resolution: Qt.size(20, 20)
    }
    property variant source: Image {
        source: "qt-logo.png"
        sourceSize { width: 200; height: 200 }
    }
    vertexShader: "gridmesh.vert"
}
#version 440
layout(location = 0) in vec4 qt_Vertex;
layout(location = 1) in vec2 qt_MultiTexCoord0;
layout(location = 0) out vec2 qt_TexCoord0;
layout(std140, binding = 0) uniform buf {
    mat4 qt_Matrix;
    float qt_Opacity;
    float width;
};
void main() {
    vec4 pos = qt_Vertex;
    float d = 0.5 * smoothstep(0.0, 1.0, qt_MultiTexCoord0.y);
    pos.x = width * mix(d, 1.0 - d, qt_MultiTexCoord0.x);
    gl_Position = qt_Matrix * pos;
    qt_TexCoord0 = qt_MultiTexCoord0;
}

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.