qml XmlListModel plugin not found

2019-05-10 04:11发布

In my project I'm trying to use the Xml List Module built in to qml but when I compile to a phone I get this error

W/Qt      (20100): assets:/qml/FlickrDemo/main.qml:4 ((null)): assets:/qml/FlickrDemo/main.qml:4:1: module "QtQuick.XmlListModel" plugin "qmlxmllistmodelplugin" not found

any help would be really appreciated. Thanks

UPDATE

with both of the sudgested imports I just get this output on both my samsung galaxy note 2 and vivo

E/        ( 8142): Device driver API match
E/        ( 8142): Device driver API version: 23
E/        ( 8142): User space API version: 23 
E/        ( 8142): mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Fri Nov 29 14:18:37 KST 2013 
D/OpenGLRenderer( 8142): Enabling debug mode 0
W/Qt      ( 8142): assets:/qml/Demo2/main.qml:4 ((null)): assets:/qml/Demo2/main.qml:4:1: module "QtQuick.XmlListModel" plugin "qmlxmllistmodelplugin" not found 

UPDATE 2

.pro file

# Add more folders to ship with the application, here
folder_01.source = qml/Demo2
folder_01.target = qml
DEPLOYMENTFOLDERS = folder_01

# Additional import path used to resolve QML modules in Creator's code model
QML_IMPORT_PATH =

QT += qml quick network positioning

# The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp

# Installation path
# target.path =

QT += xmlpatterns xml

# Please do not modify the following two lines. Required for deployment.
include(qtquick2applicationviewer/qtquick2applicationviewer.pri)
qtcAddDeployment()

main.qml

import QtQuick 2.0
import QtQuick.Controls.Styles 1.1
import QtQuick.Controls 1.1
import QtQuick.XmlListModel 2.0

Rectangle {
    id:screen
    height: 1280; width: 720

    XmlListModel{
        id:listmodel
        source:"http://api.flickr.com/services/feeds/photos_public.gne?tags=dogs"
        query:"/feed/entry"
        namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
        XmlRole{name:"img_title"; query: "title/string()"}
        XmlRole{name:"img_source";query:"link[@rel=\"alternate\"]/@href/string()"}
    }

    transitions:[
        Transition{
            NumberAnimation{
                target:layout
                property:"x"
                easing: Easing.OutSine
                duration:250
            }

        }
    ]
    states: [
        State {
            name: "view"
            PropertyChanges {
                target: layout
                x:-screen.width
            }
            PropertyChanges {
                target: btn_back
                opacity:1
            }
            PropertyChanges {
                target: te_search
                opacity:0
            }
            PropertyChanges {
                target: btn_search
                opacity:0
            }
        }
    ]

    Row{
        id:layout
        height:screen.height - te_search.height

        ListView {
            id: listview
            width:screen.width
            height:screen.height - te_search.height
            clip:true

            model: listmodel

            delegate: Item {
                width:parent.width
                height:80
                Image {
                    id:thumbnail
                    width:parent.height
                    height:parent.height
                    anchors.left:parent.left
                    //source:img_source
                    source:"http://t2.gstatic.com/images?q=tbn:ANd9GcTrUkD2AQtkUmcazQ0P9JCxJBn-_lMHiRI2XdiB5s17ho6dv3UP"
                    onSourceChanged: print("Your image source is : " + img_source)
                }
                Text{
                    id:txt_title
                    anchors.left:thumbnail.right
                    anchors.leftMargin: 5
                    anchors.right: txt_arrow.right
                    anchors.verticalCenter: parent.verticalCenter
                    font.pixelSize: 20
                    elide:Text.ElideMiddle
                    text:img_title
                }
                Text{
                    id:txt_arrow
                    anchors.right: parent.right
                    anchors.rightMargin: 10
                    anchors.verticalCenter: parent.verticalCenter
                    font.pixelSize: 25
                    text:">>"
                }
                MouseArea{
                    anchors.fill: parent
                    onClicked:{
                        console.log("clicked")
                        screen.state = "view"
                        console.log(img_source + " " + img_title)
                    }
                }
            }
        }
        Image{
            id:big_pic
            width:screen.width
            height: screen.width - te_search.height - 10
            fillMode:Image.PreserveAspectFit
            source: "http://www.hq.xinhuanet.com/photo/2013-02/04/114603916_21n.jpg"
            //source: img_source
        }
    }

    CTextInput{
        id:te_search
        y: 321
        height: 31
        anchors.right: btn_search.left
        anchors.left: screen.left
        anchors.leftMargin: 5
        anchors.bottom: screen.bottom
        anchors.bottomMargin: 5
        Behavior on opacity {NumberAnimation{}}
        text:"Search Pics"
    }

    Button {
        id: btn_search
        height: te_search.height
        x: 276
        y: 326
        text: qsTr("Search")
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 0
        Behavior on opacity {NumberAnimation{}}
        anchors.right: screen.right
        anchors.rightMargin: 5
    }

    Button {
        id: btn_back
        height: te_search.height
        x: 276
        y: 326
        opacity: 0
        text: qsTr("<< Back")
        Behavior on opacity {NumberAnimation{}}
        anchors.left: screen.left
        anchors.leftMargin: 5
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 0
        onClicked: screen.state = ""
    }

    Text{
        x: 0
        y: 0
        anchors.top: screen.top
        text:"Tester"
        horizontalAlignment: Text.AlignHCenter
        font.pixelSize: 70
    }
}

标签: xml qml
1条回答
家丑人穷心不美
2楼-- · 2019-05-10 05:08

[UPDATED]

try to add XML support to your .pro file

 QT + = xmlpatterns xml

[UPDATE 2] try also

Projects --->Android kit armeabi-v7 ---> run ---> Deploy configurations 

--->additional libraries --->add  

---> browse toQTpath/.../android_armv7/qml/QtQuick/XmlListModel 

and choose libqmlxmllistmodelplugin.so

查看更多
登录 后发表回答