Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. German
  4. RSS-Feeds automatisch aktualisieren
QtWS25 Last Chance

RSS-Feeds automatisch aktualisieren

Scheduled Pinned Locked Moved Unsolved German
8 Posts 2 Posters 915 Views
  • 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.
  • MarkusWiLinuxM Offline
    MarkusWiLinuxM Offline
    MarkusWiLinux
    wrote on last edited by
    #1

    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.HilkJ 1 Reply Last reply
    0
    • MarkusWiLinuxM MarkusWiLinux

      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.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @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


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

      MarkusWiLinuxM 1 Reply Last reply
      0
      • J.HilkJ J.Hilk

        @MarkusWiLinux said in RSS-Feeds automatisch aktualisieren:

        RssInfo.qml

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

        MarkusWiLinuxM Offline
        MarkusWiLinuxM Offline
        MarkusWiLinux
        wrote on last edited by
        #3

        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()
                }
            }
        }
        

        }

        MarkusWiLinuxM 1 Reply Last reply
        0
        • MarkusWiLinuxM MarkusWiLinux

          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()
                  }
              }
          }
          

          }

          MarkusWiLinuxM Offline
          MarkusWiLinuxM Offline
          MarkusWiLinux
          wrote on last edited by
          #4

          @MarkusWiLinux
          Nützt dir der Code was?

          J.HilkJ 1 Reply Last reply
          0
          • MarkusWiLinuxM MarkusWiLinux

            @MarkusWiLinux
            Nützt dir der Code was?

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @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


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

            MarkusWiLinuxM 1 Reply Last reply
            0
            • J.HilkJ J.Hilk

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

              MarkusWiLinuxM Offline
              MarkusWiLinuxM Offline
              MarkusWiLinux
              wrote on last edited by
              #6

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

              J.HilkJ 1 Reply Last reply
              0
              • MarkusWiLinuxM MarkusWiLinux

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

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by J.Hilk
                #7

                @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


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

                MarkusWiLinuxM 1 Reply Last reply
                1
                • J.HilkJ 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 🤷‍♂️

                  MarkusWiLinuxM Offline
                  MarkusWiLinuxM Offline
                  MarkusWiLinux
                  wrote on last edited by
                  #8

                  @J-Hilk Danke. Ich probiers mal aus.

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved