summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2017-09-19 15:30:48 +0200
committerGatis Paeglis <gatis.paeglis@qt.io>2017-09-26 08:46:52 +0000
commit9e26cfa167778f3d9444aedcb23c8476683b3785 (patch)
tree2eb7beb467cbe69f7ec5987e03c1dff8a490fcd2 /examples
parent189c0c1ad9ae2dee6359ec0cde6049fdf4c6aaf1 (diff)
downloadqtxmlpatterns-9e26cfa167778f3d9444aedcb23c8476683b3785.tar.gz
examples: minor code revamping in recipesv5.10.0-beta3v5.10.0-beta2v5.10.0-beta1
Task-number: QTBUG-60660 Change-Id: I396f64c770f4ccbf5b2bbd6240ccb4618df70b23 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/xmlpatterns/recipes/querymainwindow.cpp17
-rw-r--r--examples/xmlpatterns/recipes/querymainwindow.h2
-rw-r--r--examples/xmlpatterns/shared/xmlsyntaxhighlighter.h2
3 files changed, 11 insertions, 10 deletions
diff --git a/examples/xmlpatterns/recipes/querymainwindow.cpp b/examples/xmlpatterns/recipes/querymainwindow.cpp
index 9a543d5..f24185b 100644
--- a/examples/xmlpatterns/recipes/querymainwindow.cpp
+++ b/examples/xmlpatterns/recipes/querymainwindow.cpp
@@ -38,15 +38,15 @@
**
****************************************************************************/
-#include <QMessageBox>
-#include <QFileDialog>
+#include <QtWidgets/QMessageBox>
+#include <QtWidgets/QFileDialog>
#include <QtXmlPatterns>
#include "querymainwindow.h"
#include "xmlsyntaxhighlighter.h"
//! [0]
-QueryMainWindow::QueryMainWindow() : ui_defaultQueries(0)
+QueryMainWindow::QueryMainWindow()
{
setupUi(this);
@@ -55,14 +55,15 @@ QueryMainWindow::QueryMainWindow() : ui_defaultQueries(0)
ui_defaultQueries = findChild<QComboBox*>("defaultQueries");
QMetaObject::connectSlotsByName(this);
- connect(ui_defaultQueries, SIGNAL(currentIndexChanged(int)), SLOT(displayQuery(int)));
+
+ connect(ui_defaultQueries, QOverload<int>::of(&QComboBox::currentIndexChanged),
+ this, &QueryMainWindow::displayQuery);
loadInputFile();
const QStringList queries(QDir(":/files/", "*.xq").entryList());
- int len = queries.count();
- for(int i = 0; i < len; ++i)
- ui_defaultQueries->addItem(queries.at(i));
- if (len > 0)
+ for (const auto &query : queries)
+ ui_defaultQueries->addItem(query);
+ if (queries.count() > 0)
displayQuery(0);
}
//! [0]
diff --git a/examples/xmlpatterns/recipes/querymainwindow.h b/examples/xmlpatterns/recipes/querymainwindow.h
index 25ffaab..7961d88 100644
--- a/examples/xmlpatterns/recipes/querymainwindow.h
+++ b/examples/xmlpatterns/recipes/querymainwindow.h
@@ -62,7 +62,7 @@ public slots:
void displayQuery(int index);
private:
- QComboBox* ui_defaultQueries;
+ QComboBox *ui_defaultQueries = nullptr;
void evaluate(const QString &str);
void loadInputFile();
diff --git a/examples/xmlpatterns/shared/xmlsyntaxhighlighter.h b/examples/xmlpatterns/shared/xmlsyntaxhighlighter.h
index 7a104d5..bdd379c 100644
--- a/examples/xmlpatterns/shared/xmlsyntaxhighlighter.h
+++ b/examples/xmlpatterns/shared/xmlsyntaxhighlighter.h
@@ -47,7 +47,7 @@
class XmlSyntaxHighlighter : public QSyntaxHighlighter
{
public:
- XmlSyntaxHighlighter(QTextDocument *parent = 0);
+ explicit XmlSyntaxHighlighter(QTextDocument *parent = nullptr);
protected:
virtual void highlightBlock(const QString &text);