A
A
Asya2017-06-05 12:59:12
Qt
Asya, 2017-06-05 12:59:12

How to save the news text to a text file?

Let's say I receive news using rss, how can I write the text of this news and its name to a text file?

the code
import QtQuick 2.2
import QtQuick.XmlListModel 2.0
import QtQuick.Window 2.1
import QtQuick.Controls 1.1
import QtQuick.Extras 1.4
//import "./content"

Rectangle {
    id: window

    width: 680
    height: 800
    visible: true

    property string currentFeed: rssFeeds.get(0).feed
    property bool loading: feedModel.status === XmlListModel.Loading
    property bool isPortrait: Screen.primaryOrientation === false
                              //Qt.PortraitOrientation

    onLoadingChanged: {
        if (feedModel.status == XmlListModel.Ready)
            list.positionViewAtBeginning()
    }
    RssFeeds { id: rssFeeds }

    property var feeds: [
        { name: "NASA", feed: "http://www.nasa.gov/rss/dyn/solar_system.rss", icon: "awesome/rss"}
    ]

    property var selectedFeed: feeds[0]


    XmlListModel {
        id: feedModel
        source: selectedFeed.feed
        query: "/rss/channel/item"

        XmlRole { name: "title"; query: "title/string()"}
        XmlRole { name: "description"; query: "description/string()"}
        XmlRole { name: "image"}
        XmlRole { name: "link"; query: "link/string()" }
        XmlRole { name: "pubDate"; query: "pubDate/string()" }
    }


    ListView {
        id: categories
        property int itemWidth: 300

        width: isPortrait ? parent.width : itemWidth
        height: isPortrait ? itemWidth : parent.height
        orientation: isPortrait ? ListView.Horizontal : ListView.Vertical
        anchors.top: parent.top
        model: rssFeeds
        delegate: CategoryDelegate { itemSize: categories.itemWidth }
        spacing: 5
    }


    ListView {
        id: list

        anchors.left: isPortrait ? window.left : categories.right
        anchors.right: closeButton.left
        anchors.top: isPortrait ? categories.bottom : window.top
        anchors.bottom: window.bottom
        anchors.leftMargin: 30
        anchors.rightMargin: 4
        clip: isPortrait
        model: feedModel
        footer: footerText
        delegate: NewsDelegate {}
    }

}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel K, 2017-06-18
@asyaevloeva

Directly from qml - no way, you have to turn to c++.
An example class is here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question