rsslisting example: move default URL to main()

It felt more natural that the RSSListing class would be agnostic about
the default URL, so let it be a constructor parameter. In the process,
update the URL to what the old one now redirects to (thanks to Ivan
Solovev for spotting that) and make the constructor explcit (thaks to
Ievgenii Meshcheriakov for suggesting this).

Task-number: QTBUG-111228
Pick-to: 6.5
Change-Id: I9f4c0d126e0872bb4ec6e6bb41add7e9d2a9537f
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
This commit is contained in:
Edward Welbourne 2023-05-05 17:58:26 +02:00
parent 3cdc65c2ec
commit 233ca06500
3 changed files with 5 additions and 4 deletions

View File

@ -9,6 +9,7 @@ Provides the main function for the RSS news reader example.
#include "rsslisting.h"
#include <QtWidgets>
using namespace Qt::StringLiterals;
/*!
Create an application and a main widget. Open the main widget for
@ -19,7 +20,7 @@ Provides the main function for the RSS news reader example.
int main(int argc, char **argv)
{
QApplication app(argc, argv);
RSSListing rsslisting;
RSSListing rsslisting(u"https://www.qt.io/blog/rss.xml"_s);
rsslisting.show();
return app.exec();
}

View File

@ -32,12 +32,12 @@ its operation, and also allows very large data sources to be read.
news.
*/
RSSListing::RSSListing(QWidget *parent)
RSSListing::RSSListing(const QString &url, QWidget *parent)
: QWidget(parent), currentReply(0)
{
lineEdit = new QLineEdit(this);
lineEdit->setText("http://blog.qt.io/feed/");
lineEdit->setText(url);
fetchButton = new QPushButton(tr("Fetch"), this);

View File

@ -21,7 +21,7 @@ class RSSListing : public QWidget
{
Q_OBJECT
public:
RSSListing(QWidget *widget = nullptr);
explicit RSSListing(const QString &url = QString(), QWidget *widget = nullptr);
public slots:
void fetch();