1.main.cpp

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQuickItem>
#include <QVariant>
#include <QDebug>
#include "jsondata.h"
#include "testdata.h"
int main(int argc, char *argv[])
{
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); TestData *testData=new TestData(); QQmlApplicationEngine engine;
JsonData jsondata;
engine.rootContext()->setContextProperty("jsondata",&jsondata); engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -; //QQuickItem* item = engine.rootObjects().at(0)->findChild<QQuickItem*>("tableview");
//qDebug() << item->objectName();
//QObject::connect (testData,SIGNAL (sendToQml(QVariant)),item,SLOT(addRowData(QVariant))); //QString jsonData="[{\"task_name\":\"task1\",\"task_status\":\"ok\",\"task_time\":\"2019_2_16\"}]";
//QMetaObject::invokeMethod(item, "addRowData", Q_ARG(QVariant, jsonData)); //调用函数 return app.exec();
}

main.qml

import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
import QtQuick.Controls.Styles 1.4
import QtQuick.Window 2.2
import QtQuick.VirtualKeyboard 2.2 Window {
id: window
visible: true
width:
height:
title: qsTr("Forklift") property var jsonData: JSON.parse(jsondata.getJsonData)
readonly property color bgColor: "#40434A"
readonly property color borderColor: "#6affcd"
readonly property color colorLightGrey: "#888"
color: bgColor Rectangle{
id: container
anchors.fill: parent
anchors.margins:
border.color:borderColor
border.width:
color: bgColor
smooth: true
RowLayout{
id: mainRowLayout
anchors.fill: parent
anchors.margins:
spacing: Rectangle{
id:leftRect
Layout.fillHeight: true
Layout.minimumWidth:
Layout.preferredWidth:
Layout.maximumWidth:
Layout.minimumHeight:
border.color: borderColor
color: bgColor
border.width:
smooth: true // TableViewItem{
// id:taskTableView
// anchors.fill: parent
// objectName: "tableview" // } ListView{
id:taskListview
anchors.fill: parent
anchors.margins:
model: jsonData
delegate: tableModel }
Component{
id:tableModel
RowLayout{
spacing:
Layout.fillWidth:true
Label{
text: jsonData[index].name
color:borderColor
}
Label{
text: jsonData[index].age
color:borderColor
}
}
} } Rectangle {
color: borderColor
implicitWidth:
Layout.fillHeight: true
} Rectangle{
id:centerRect
Layout.fillHeight: true
Layout.minimumWidth:
Layout.preferredWidth:
Layout.maximumWidth:
Layout.minimumHeight:
color: bgColor
Label{
text: qsTr("01/01/2018")
color: colorLightGrey
font.pixelSize: Layout.alignment: Qt.AlignHCenter
Layout.topMargin:
Layout.bottomMargin:
} ColumnLayout{
Layout.preferredWidth:
Layout.fillWidth: true
Layout.fillHeight: true
Image{
source: "qrc:/icons/car.png"
fillMode: Image.PreserveAspectFit
Layout.fillHeight: true
}
} } Rectangle {
color: borderColor
implicitWidth:
Layout.fillHeight: true
} Rectangle{
id:rightRect
Layout.fillHeight: true
Layout.minimumWidth:
Layout.preferredWidth:
Layout.maximumWidth:
Layout.minimumHeight: } } } InputPanel {
id: inputPanel
z:
x:
y: window.height
width: window.width states: State {
name: "visible"
when: inputPanel.active
PropertyChanges {
target: inputPanel
y: window.height - inputPanel.height
}
}
transitions: Transition {
from: ""
to: "visible"
reversible: true
ParallelAnimation {
NumberAnimation {
properties: "y"
duration:
easing.type: Easing.InOutQuad
}
}
}
}
}

QML ListView json的更多相关文章

  1. Qt qml listview 列表视图控件(下拉刷新、上拉分页、滚动轴)

    Qt qml listview下拉刷新和上拉分页主要根据contentY来判断.但要加上顶部下拉指示器.滚动条,并封装成可简单调用的组件,着实花了我不少精力:) [先看效果]    [功能] 下拉刷新 ...

  2. Android之ListView&Json加载网络数据

    使用到的主要内容: 1.Json 解析网络数据 2.异步任务加载图片和数据 3.ListView 的内存空间优化(ConvertView)和运行时间优化(ViewHolder) 4.ListView ...

  3. ★android开发--ListView+Json+异步网络图片加载+滚动翻页的例子(图片能缓存,图片不错乱)

    例子中用于解析Json的Gson请自己Google下载 主Activity: package COM.Example.Main; import java.util.HashMap; import ja ...

  4. QML学习笔记(五)— 做一个简单的待做事项列表

    做一个简单的QML待做事项列表,能够动态添加和删除和编辑数据 GitHub:八至 作者:狐狸家的鱼 本文链接:QML学习笔记(五)— 做一个待做事项列表 主要用到QML:ListView 效果 全部代 ...

  5. QtQuick大坑笔记之Http的Get与Post操作(带cookie)

    前言 最近在为单位做一个简单的手机App,基于Qt技术栈的选择了QtQuick来开发.不得不说QtQucik开发的确舒服,很多东西都不用写就可以只用,UI定义起来也比较自由.但是本人想通过cookie ...

  6. android内部培训视频_第四节(1)_异步网络操作

    第四节(1):异步网络操作  一.结合asyncTask下载网络图片 1.定义下载类,继承自asyncTask,参数分别为:String(url地址),Integer(刻度,本例没有用到),BitMa ...

  7. html__脚本之家

    深入剖析Android的Volley库中的图片加载功能 Android图片加载缓存框架Glide Android程序开发ListView+Json+异步网络图片加载+滚动翻页的例子(图片能缓存,图片不 ...

  8. qml json 解析到 ListView

    https://github.com/kromain/qml-utils/tree/master/JSONListModel 非常棒!! 实现的原理如下文: http://goessner.net/a ...

  9. Android获取服务器Json字符串并显示在ListView上面

    已经好久没有更新博客,今天终于有新的东西可以记录了. 通过这次的任务学习到了以前没有注意到的知识点,真的有种书读百遍,其义自见的感觉.这次又重新认识了<Handler消息机制原理>.这次的 ...

随机推荐

  1. Bootstrap开发框架界面的调整处理

    我在之前介绍了很多关于Boostrap的框架方面的文章,主要是介绍各种插件的使用居多,不过有时候觉得基于Metronic的Boostrap框架的界面效果不够紧凑,希望对它进行一定的调整,那么我们应该如 ...

  2. mysql常见问题处理

    出现: Access denied for user ''@'localhost' to database ' 2.error: Found option without preceding grou ...

  3. Python Revisited Day 05(模块)

    目录 5.1 模块与包 5.1.1 包 5.2 Python 标准库概览 5.2.1 字符串处理 io.StringIO 类 5.2.3 命令行设计 5.2.4 数学与数字 5.2.5 时间与日期 5 ...

  4. CSL 的魔法

    链接 [https://ac.nowcoder.com/acm/contest/551/E] 分析 很显然就是a的第k大得和b的倒数第k大相乘. 那么我们只要让a的第k大和b的倒数第k大位置是相同的即 ...

  5. CGPoint、CGSize、CGRect、CGRectEdge的详细使用

    http://blog.sina.com.cn/s/blog_953e22700101r7lz.html 在CGGeometry.h里的 CGPoint.CGSize.CGRect.CGRectEdg ...

  6. Django rest framework(8)---- 视图和渲染器

    django rest framework 之视图 序列化器    PagerSerialiser from rest_framework import serializers from api im ...

  7. 【win7】安装php7.3及扩展

    php7.3插件php-redisphp-igbinaryphp-amqp [初识RabbitMQ,附RabbitMQ+PHP演示实例]https://www.cnblogs.com/miketwai ...

  8. python之常用模块一(time、random、os、sys)

    摘要:时间模块time .随机模块random .os模块.sys模块 一.时间模块 三种格式 时间戳时间:浮点数 单位为秒 时间戳起始时间: 1970.1.1 0:0:0 英国伦敦时间 1970.1 ...

  9. Spring中的AOP 专题

    Caused by: java.lang.IllegalArgumentException: ProceedingJoinPoint is only supported for around advi ...

  10. linux镜像下载

    https://blog.csdn.net/qq_42570879/article/details/82853708