QML轮播图效果

 

  • mian.qml:qml界面代码
  • datamodel:自定的数据Model,包含一个图片地址和一句说明文字,用于填充qml界面
  • mian.cpp:加载qml界面,设置datamodel,显示quickview

 

main.qml

import QtQuick 2.8
import QtQuick.Window 2.2

Rectangle {
    id: root

    property int itemCount: 5

    visible: true
    width: 800
    height: 600
    color: "black"

    PathView {
        id: pathView
        anchors.fill: parent
        model: DataModel

        delegate: Item {
            id: delegateItem

            property var infoText: model.info

            width: 200
            height: 200
            z: PathView.iconZ
            scale: PathView.iconScale

            Image {
                id: image
                antialiasing: true
                source: model.url
                width: delegateItem.width
                height: delegateItem.height
            }

            ShaderEffect {
                anchors.top: image.bottom
                width: image.width
                height: image.height;
                anchors.left: image.left
                property variant source: image;
                property size sourceSize: Qt.size(0.5 / image.width, 0.5 / image.height);
                fragmentShader:
                    "varying highp vec2 qt_TexCoord0;
                    uniform lowp sa
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值