Re: [Interest] Qt Quick UI Forms item views: best practices

2015-01-21 Thread Ola Røer Thorsen

Den 2015-01-21 09:24, skrev Alexander Ivash:
Yes, your are right, there was an error in my sample, but even fixing 
it doesn't change a lot: ui.qml files becomes not editable via 
QtCreator's QML designer due to presence


onClicked: root.onClicked(root.model.get(index)); /// this line makes 
QtCreator unhappy :(




As far as I have understood it, the whole idea of the ui.qml files are 
that they should not contain any javascript whatsoever. It's very 
difficult to develop a designer that understands what to do with 
javascript snippets while only working on a single file from a larger 
application.


You have to expose all items in your .ui.qml file via property aliases, 
and do all your logic code from the outside. The regular qtcreator 
designer doesn't have any button for exposing items as properties so you 
need to add them in the text editor manually. The commercial edition of 
qtcreator has such a button I think.


It's a bit confusing for new users. The default Quick project in 
QtCreator makes an example .ui.qml file with 3 buttons exposed as 
property aliases, and shows how to use them. It warns the user not to 
edit these ui.qml files by hand. Still, .ui.qml files are mostly useless 
if you don't create any property aliases, which you have to do by typing 
them into the text editor.


Maybe you could try something like this (haven't tested it myself):

Form.ui.qml
Item {
   property alias listView: theListView

   ListView {
  id: theListView
   }
}

Delegate.ui.qml
Item {
   property alias ma: mouseArea
   MouseArea {
  id: mouseArea
  anchors.fill: parent
  }
}

main.qml
Item {
   Form {
  listView.delegate: Delegate {
 ... javascript and bindings here.. .
  }
   }
}



___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt Quick UI Forms item views: best practices

2015-01-21 Thread Alexander Ivash
Yes, your are right, there was an error in my sample, but even fixing it
doesn't change a lot: ui.qml files becomes not editable via QtCreator's QML
designer due to presence

onClicked: root.onClicked(root.model.get(index)); /// this line makes
QtCreator unhappy :(

2015-01-21 10:16 GMT+03:00 Kristoffersen, Even (NO14) 
even.kristoffer...@honeywell.com:

  From: Alexander Ivash
  Sent: 20. januar 2015 19:32
  To: interest@qt-project.org
  Subject: [Interest] Qt Quick UI Forms  item views: best practices

  MouseArea {
  onClicked: root.onClicked(root.model.get(index)); /// this line makes
 QtCreator unhappy :(
  }

 Shouldn’t that be root.itemClicked(root.model.get(index)); ?

 -Even

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] Qt Quick UI Forms item views: best practices

2015-01-20 Thread Alexander Ivash
I was trying to apply new feature (Qt Quick UI Forms) to like to create a
custom ListView with a custom delegate, but quickly found that I'm not sure
how to propagate signal from delegate to ListView to expose it as the part
of custom ListView's API.

Probably I'm missing something, but what is the best practices on using Qt
Quick UI Forms together with item views? It seems for me like currently
only ListView itself can be defined inside the *.ui.qml file, and the
delegate needs to be defined inside the corresponding *.qml file. Which
significantly decreases benefits of the whole approach.

Here is the short sample of what I'm trying to achieve:

Customlistview.ui.qml:

CustomListViewForm {
id: root
signal itemClicked(item)
.
delegate: Rectangle {

MouseArea {
onClicked: root.onClicked(root.model.get(index)); /// this line makes
QtCreator unhappy :(
}
}
}


Customlistview.qml:

CustomViewForm {
   onItemClicked: {

   }
}

Any ideas/suggestions? Thanks!
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt Quick UI Forms item views: best practices

2015-01-20 Thread Kristoffersen, Even (NO14)
 From: Alexander Ivash
 Sent: 20. januar 2015 19:32
 To: interest@qt-project.org
 Subject: [Interest] Qt Quick UI Forms  item views: best practices

 MouseArea {
 onClicked: root.onClicked(root.model.get(index)); /// this line makes 
 QtCreator unhappy :(
 }

Shouldn’t that be root.itemClicked(root.model.get(index)); ?

-Even
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest