[Interest] ListView text item delegate property setting issue

Steve Pavao vstevenpavao at yahoo.com
Sat Mar 9 16:57:19 CET 2013


Hi Nils,

Thanks!  Using listModel.index === listView.currentIndex worked for me, given that listModel and listView are the id's of the instances.

I am fairly new to QML programming and still learning the API, and hadn't thought of using the model.index concept in the delegate.  I don't have a lot of Javascript experience either. I'm just getting used to how to take advantage of the way scoping works in QML.

- Steve Pavao aka VStevenP

--- On Fri, 3/8/13, Nils Jeisecke <njeisecke at saltation.de> wrote:

> From: Nils Jeisecke <njeisecke at saltation.de>
> Subject: Re: [Interest] ListView text item delegate property setting issue
> To: interest at qt-project.org
> Date: Friday, March 8, 2013, 3:43 AM
> Hi,
> 
> On Fri, Mar 8, 2013 at 1:41 AM, Steve Pavao <vstevenpavao at yahoo.com>
> wrote:
> > The problem I am having is that I haven't found a
> reliable way to be able to set the
> > associated text delegate's font.bold and font.pixelSize
> properties once I set the
> > ListView's currentIndex to that desired value
> > programatically.  (I want the text for the item at
> the currentIndex to show in bold
> > and at a larger pixelSize).
> 
> Doesn't this pattern work for you?
> 
> import QtQuick 1.1
> 
> Rectangle {
>   width: 360
>   height: 360
>   ListView {
>     anchors.fill: parent
>     model: 10
>     delegate: Text {
>       id: delegate
>       font.bold: model.index ===
> delegate.ListView.view.currentIndex
>       font.pixelSize: model.index ===
> delegate.ListView.view.currentIndex ? 20 : 16
>       text: modelData
>       MouseArea {
>         anchors.fill: parent
>         onClicked:
> delegate.ListView.view.currentIndex = model.index
>       }
>     }
>   }
> }
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
> 



More information about the Interest mailing list