Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved RSS-Feeds automatisch aktualisieren

    German
    2
    8
    446
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • MarkusWiLinux
      MarkusWiLinux last edited by

      Hallo,
      ich hätte da mal eine generelle Frage zum technisch/logischen Ablauf zu den RSS-Feeds.

      Ich hab mit in eine C++ - Anwendung auf ein Widget ein qml-File gelegt. Diese qml-File liest mir
      RSS-Feeds ein und zeigt diese auch wunderbar an. Hier mal der Code dazu:

      QQuickView *view = new QQuickView();
      view->setResizeMode(QQuickView::SizeRootObjectToView);
      QWidget *container = QWidget::createWindowContainer(view, ui->rssWidget);

      view->setSource(QUrl::fromLocalFile("RssInfo.qml"));
      
      QObject *item = view->rootObject();
      connect(item, SIGNAL(sendQmlLink(QString)),  SLOT(cppQmlLinkSlot(QString)));
      ui->rssWidget->layout()->addWidget(container);
      

      Nun möchte ich z.B. alle 5 Minuten die Seiten aktuell laden.

      1. Mache ich das im qml-File und wenn ja wie?
      2. Starte ich im C++-File einen "Loop" der mir den erzeugten Container löscht und neu erstellt?

      Danke um Vorraus.

      J.Hilk 1 Reply Last reply Reply Quote 0
      • J.Hilk
        J.Hilk Moderators @MarkusWiLinux last edited by

        @MarkusWiLinux said in RSS-Feeds automatisch aktualisieren:

        RssInfo.qml

        das kommt drauf an, wie kommen die Infos ursprünglich in die RssInfo.qml ?

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

        Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        MarkusWiLinux 1 Reply Last reply Reply Quote 0
        • MarkusWiLinux
          MarkusWiLinux @J.Hilk last edited by

          Rectangle {
          id: window

          width: 800
          height: 1000
          //    width: parent.width - 1
          //    height: parent.height - 1
          property string currentFeed: rssFeeds.get(0).feed
          property bool loading: feedModel.status === XmlListModel.Loading
          property bool isPortrait: Screen.primaryOrientation === Qt.PortraitOrientation
          
          signal sendQmlLink(string xLink)
          
          
          onLoadingChanged: {
              if (feedModel.status == XmlListModel.Ready)
                  list.positionViewAtBeginning()
          }
          
          RssFeeds {
              id: rssFeeds
          }
          
          XmlListModel {
              id: feedModel
          
              source: "http://" + window.currentFeed
          
              //query: "/rss/channel/item"
              query: "/rss/channel/item[child::media:content]"
              namespaceDeclarations: "declare namespace media = 'http://search.yahoo.com/mrss/';"
          
              XmlRole {
                  name: "title"
                  query: "title/string()"
              }
              // Remove any links from the description
              XmlRole {
                  name: "description"
                  query: "fn:replace(description/string(),  '\<a href=.*\/a\>', '')"
              }
              XmlRole {
                  name: "image"
                  query: "media:content/@url/string()"
              }
              XmlRole {
                  name: "link"
                  query: "link/string()"
              }
              XmlRole {
                  name: "pubDate"
                  query: "pubDate/string()"
              }
          }
          
          ListView {
              id: categories
              property int itemWidth: 190
          
              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: 3
          }
          
          ScrollBar {
              id: listScrollBar
          
              orientation: isPortrait ? Qt.Horizontal : Qt.Vertical
              height: isPortrait ? 8 : categories.height
              width: isPortrait ? categories.width : 8
              scrollArea: categories
              anchors.right: categories.right
          }
          
          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 {}
          }
          
          ScrollBar {
              scrollArea: list
              width: 10
              anchors.right: window.right
              anchors.top: isPortrait ? categories.bottom : window.top
              anchors.bottom: window.bottom
          }
          
          Component {
              id: footerText
          
              Rectangle {
                  width: parent.width
                  height: closeButton.height
                  color: "lightgray"
          
                  Text {
                      text: "RSS Feed von Apotheke ADHOC"
                      anchors.centerIn: parent
                      font.pixelSize: 14
                  }
              }
          }
          
          Image {
              id: closeButton
              source: "images/btn_close.png"
              scale: 0.8
              anchors.top: parent.top
              anchors.right: parent.right
              anchors.margins: 4
              opacity: (isPortrait && categories.moving) ? 0.2 : 1.0
              Behavior on opacity {
                  NumberAnimation {
                      duration: 300
                      easing.type: Easing.OutSine
                  }
              }
          
              MouseArea {
                  anchors.fill: parent
                  onClicked: {
                      Qt.quit()
                  }
              }
          }
          

          }

          MarkusWiLinux 1 Reply Last reply Reply Quote 0
          • MarkusWiLinux
            MarkusWiLinux @MarkusWiLinux last edited by

            @MarkusWiLinux
            Nützt dir der Code was?

            J.Hilk 1 Reply Last reply Reply Quote 0
            • J.Hilk
              J.Hilk Moderators @MarkusWiLinux last edited by

              @MarkusWiLinux das kommt drauf an 😉
              is RssFeed
              das File von diesem Beispiel?
              https://doc.qt.io/qt-5/qtdoc-demos-rssnews-example.html

              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

              Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              MarkusWiLinux 1 Reply Last reply Reply Quote 0
              • MarkusWiLinux
                MarkusWiLinux @J.Hilk last edited by

                @J-Hilk Genau :-)
                Ich hab's mir etwas angepasst.

                J.Hilk 1 Reply Last reply Reply Quote 0
                • J.Hilk
                  J.Hilk Moderators @MarkusWiLinux last edited by J.Hilk

                  @MarkusWiLinux
                  ok

                  ich hab mit dem Beispiel leider noch nicht wirklich gerarbeitet, aber vom drüber gucken würde ich sagen, du Updates den news feed, indem du einen reload der links erzwingst.

                  Das tust du, indem du in dem Beispiel zumindest, rssFeeds.get(0).feed also currentFeed änderst, z.b. setzt es zu rssFeeds.get(1).feed und anschließend wieder zurück auf rssFeeds.get(0).feed

                  stellt sich heraus, listmodel hat ne reload Funktion feedModel.reload()
                  die kannst ,du einfach aufrufen 🤷‍♂️

                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

                  Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  MarkusWiLinux 1 Reply Last reply Reply Quote 1
                  • MarkusWiLinux
                    MarkusWiLinux @J.Hilk last edited by

                    @J-Hilk Danke. Ich probiers mal aus.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post