From e7b1bc659087ce28fbc40b3ebe79cc10462994fa Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 5 May 2023 17:53:15 +0200 Subject: [PATCH] Turn itemActivated() slot of RSS listing example into a lambda MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It needs nothing but the parameter it is passed and has no material interaction with the rest of the RSSListing class, so there's no point devoting a slot to it, much less a public one. Task-number: QTBUG-111228 Pick-to: 6.5 Change-Id: I46d572982197550801c6fa4425453fc670c6f2f1 Reviewed-by: Marc Mutz Reviewed-by: MÃ¥rten Nordheim --- .../corelib/serialization/rsslisting/rsslisting.cpp | 11 ++--------- .../corelib/serialization/rsslisting/rsslisting.h | 1 - 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/examples/corelib/serialization/rsslisting/rsslisting.cpp b/examples/corelib/serialization/rsslisting/rsslisting.cpp index 8a82991775..68dcb69047 100644 --- a/examples/corelib/serialization/rsslisting/rsslisting.cpp +++ b/examples/corelib/serialization/rsslisting/rsslisting.cpp @@ -46,7 +46,8 @@ RSSListing::RSSListing(const QString &url, QWidget *parent) treeWidget = new QTreeWidget(this); connect(treeWidget, &QTreeWidget::itemActivated, - this, &RSSListing::itemActivated); + // Open the link in the browser: + this, [](QTreeWidgetItem *item) { QDesktopServices::openUrl(QUrl(item->text(1))); }); QStringList headerLabels; headerLabels << tr("Title") << tr("Link"); treeWidget->setHeaderLabels(headerLabels); @@ -179,14 +180,6 @@ void RSSListing::parseXml() qWarning() << "XML ERROR:" << xml.lineNumber() << ": " << xml.errorString(); } -/* - Open the link in the browser -*/ -void RSSListing::itemActivated(QTreeWidgetItem *item) -{ - QDesktopServices::openUrl(QUrl(item->text(1))); -} - void RSSListing::error(QNetworkReply::NetworkError) { qWarning("error retrieving RSS feed"); diff --git a/examples/corelib/serialization/rsslisting/rsslisting.h b/examples/corelib/serialization/rsslisting/rsslisting.h index c5ac855dce..e0ad80870d 100644 --- a/examples/corelib/serialization/rsslisting/rsslisting.h +++ b/examples/corelib/serialization/rsslisting/rsslisting.h @@ -28,7 +28,6 @@ public slots: void finished(QNetworkReply *reply); void readyRead(); void metaDataChanged(); - void itemActivated(QTreeWidgetItem *item); void error(QNetworkReply::NetworkError); private: