Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.9
- import QtQuick.Controls 2.2
- Page {
- width: 600
- height: 400
- title: "Locales"
- ListModel {
- id: modelLocales
- }
- ScrollView {
- anchors.fill: parent
- ListView {
- id: lvLocales
- width: parent.width
- model: modelLocales
- delegate: ItemDelegate {
- text: descripcion + " " + idLocal
- width: parent.width
- onClicked: {
- stackView.push( "HabitacionesForm.qml" );
- }
- }
- }
- function getData() {
- console.log( "entrando")
- var xmlhttp = new XMLHttpRequest();
- var url = "http://localhost:8080/obtenerLocales";
- xmlhttp.onreadystatechange=function() {
- if (xmlhttp.readyState == XMLHttpRequest.DONE && xmlhttp.status == 200) {
- myFunction(xmlhttp.responseText);
- }
- }
- xmlhttp.open("POST", url, true);
- xmlhttp.send();
- }
- function myFunction(response) {
- var arr = JSON.parse(response);
- for(var i=0; i<arr.listaLocales.length; ++i) {
- lvLocales.model.append( {descripcion: arr.listaLocales[i].descripcion, idLocal: arr.listaLocales[i].idLocal } )
- }
- }
- Component.onCompleted: {
- getData( )
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement