Answer the question
In order to leave comments, you need to log in
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?
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question