[Qt-interest] QML: MouseArea and Row/Column
sarvesh saran
aquarian.thunder at gmail.com
Sun Mar 13 17:27:38 CET 2011
Hi,
You may try to put the row inside a rectangle and set a mouse area to the
rectangle. It all depends on how you'd like your row to react.
thanks,
Sarvesh
On Sun, Mar 13, 2011 at 9:21 PM, Christian Rüb <christian.rueb at gmx.net>wrote:
> Hi Sarvesh,
>
> thanks for your idea but the repeater would just copy a list if I see that
> right. I already have a list and a delegate.
> It's just that I packed each row in the list into a QML "Row" consisting of
> an Image and a column of 2 Text(s) and I want that whole Row to react on
> clicks:
>
> ListView {
> model: ...
> delegate: Row {
> Image {}
> Column {
> Text {}
> Text {}
> }
> MouseArea {
> id: mouseArea
> anchors.fill: parent
> onClicked: {
> }
> }
> }
> }
>
> I can get around the warnings by not use Row and Column at all but arrange
> all items only by x/y within an Item. But what would a Column/Row be for
> then?
>
> Cheers,
> Christian
>
>
> sarvesh saran wrote:
> > Hi,
> >
> > try using a repeater with a model and a delegate...let the delegate have
> a
> > mouse area.
> >
> >
> > 1. Repeater {
> > 2. model: dummyModel
> > 3. delegate: myDelegate
> > 4. }
> > 5.
> > 6. Component {
> > 7. id: myDelegate
> > 8. Rectangle {
> > 9. x: 10
> > 10. y: index*35+10
> > 11. width: 200
> > 12. height: 30
> > 13. color: "yellow"
> > 14. TextEdit {
> > 15. text: title
> > 16. font.pointSize: 18
> > 17. }
> > 18. MouseArea {
> > 19. anchors.fill: parent
> > 20. onClicked: {
> > 21. console.log("Clicked index:",index);
> > 22. title="test"
> > 23. }
> > 24. }
> > 25. }
> >
> >
> > thanks,
> > Sarvesh
> >
> >
> > On Sat, Mar 12, 2011 at 6:51 PM, Christian Rüb <christian.rueb at gmx.net
> >wrote:
> >
> > > Hi,
> > >
> > > experimenting with QML I came across the follwing:
> > >
> > > Defining a MouseArea for an element within a Row results in a warning:
> > > "QML Row: Cannot specify left, right, horizontalCenter, fill or
> centerIn
> > > anchors for items inside Row"
> > >
> > > How should it be done else? I want all items in the Row to react on the
> > > click...
> > >
> > > code snippet:
> > >
> > > Row {
> > > ...
> > > MouseArea {
> > > anchors.fill: parent
> > > onClicked: {
> > > ...
> > >
> > > Also, is this the right place to ask about QML questions? I have some
> more
> > > ;-)
> > >
> > > Cheers,
> > > Christian
> > > _______________________________________________
> > > Qt-interest mailing list
> > > Qt-interest at qt.nokia.com
> > > http://lists.qt.nokia.com/mailman/listinfo/qt-interest
> > >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110313/5eed2099/attachment.html
More information about the Qt-interest-old
mailing list