代码之家  ›  专栏  ›  技术社区  ›  marmistrz

使用QML文档库进行筛选(Qt Mobility)

  •  0
  • marmistrz  · 技术社区  · 12 年前

    我只想过滤一个艺术家的相册,但什么都不显示。

    我的代码是:

    选择ArtistPage.qml:

    import QtQuick 1.1
    import com.nokia.meego 1.0
    import QtMobility.gallery 1.1
    
    Page
    {
        id: selectArtistPage
        tools: backtoolbar
        property string selectedartist
    
        ListView
        {
            id: galleryView
            anchors.fill: parent
            clip: true
            model: artistModel
            delegate: Item
            {
                height: 60
                width: parent.width
                Button
                {
                    height: 50
                    width: parent.width - 20
                    text: (artist != "") ? artist : "(unknown artist)"
                    onClicked:
                    {
                        selectedartist = (text != "(unknown artist)") ? text : ""
                        selectAlbumPageLoader.source = "SelectAlbumPage.qml"
                        pageStack.push(selectAlbumPageLoader.item)
                    }
                }
            }
        }
    
        DocumentGalleryModel
        {
            id: artistModel
            rootType: DocumentGallery.Artist
            properties: ["artist"]
        }
    }
    

    选择相册页面.qml:

    import QtQuick 1.1
    import com.nokia.meego 1.0
    import QtMobility.gallery 1.1
    
    Page
    {
        id: selectAlbumPage
        tools: backtoolbar
        property string selectedalbum
    
        ListView
        {
            id: galleryView
            anchors.fill: parent
            clip: true
            model: albumModel
            delegate: Item
            {
                height: 60
                width: parent.width
                Button
                {
                    height: 50
                    width: parent.width - 20
                    text: (albumTitle != "") ? albumTitle : "(unknown album)"
                    onClicked:
                    {
                        selectedalbum = (text != "(unknown album)") ? text : ""
                        // here should be launching the last page
                    }
                }
            }
        }
    
        DocumentGalleryModel
        {
            id: albumModel
            rootType: DocumentGallery.Album
            properties: ["albumTitle", "artist"]
            filter: GalleryEqualsFilter
            {
                property: "artist"
                value: selectedartist
            }
        }
    }
    

    当我在SelectArtistPage中选择艺术家时,会打开另一个页面,不会绘制带有相册名称的按钮。 如果我删除过滤器,所有相册都会显示出来。

    我做错了什么?我正在为Maemo使用Qt Mobility 1.2软件包(我正在N900上测试)。

    1 回复  |  直到 12 年前
        1
  •  0
  •   marmistrz    12 年前

    这似乎是Maemo Qt Mobility中的一个bug,正如我在这里所写: http://talk.maemo.org/showpost.php?p=1254495&postcount=112