diff options
Diffstat (limited to 'examples/widgets/tutorials/modelview/7_selections')
3 files changed, 13 insertions, 13 deletions
diff --git a/examples/widgets/tutorials/modelview/7_selections/main.cpp b/examples/widgets/tutorials/modelview/7_selections/main.cpp index e1b46339b1..315875a627 100644 --- a/examples/widgets/tutorials/modelview/7_selections/main.cpp +++ b/examples/widgets/tutorials/modelview/7_selections/main.cpp @@ -48,7 +48,7 @@ ** ****************************************************************************/ -#include <QtWidgets/QApplication> +#include <QApplication> #include "mainwindow.h" int main(int argc, char *argv[]) diff --git a/examples/widgets/tutorials/modelview/7_selections/mainwindow.cpp b/examples/widgets/tutorials/modelview/7_selections/mainwindow.cpp index 200751ee6d..2b10071a68 100644 --- a/examples/widgets/tutorials/modelview/7_selections/mainwindow.cpp +++ b/examples/widgets/tutorials/modelview/7_selections/mainwindow.cpp @@ -49,17 +49,18 @@ ****************************************************************************/ //! [quoting modelview_a] +#include "mainwindow.h" + #include <QTreeView> #include <QStandardItemModel> #include <QItemSelectionModel> -#include "mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) + , treeView(new QTreeView(this)) + , standardModel(new QStandardItemModel(this)) { - treeView = new QTreeView(this); setCentralWidget(treeView); - standardModel = new QStandardItemModel ; QStandardItem *rootNode = standardModel->invisibleRootItem(); @@ -88,9 +89,9 @@ MainWindow::MainWindow(QWidget *parent) treeView->expandAll(); //selection changes shall trigger a slot - QItemSelectionModel *selectionModel= treeView->selectionModel(); - connect(selectionModel, SIGNAL(selectionChanged (const QItemSelection &, const QItemSelection &)), - this, SLOT(selectionChangedSlot(const QItemSelection &, const QItemSelection &))); + QItemSelectionModel *selectionModel = treeView->selectionModel(); + connect(selectionModel, &QItemSelectionModel::selectionChanged, + this, &MainWindow::selectionChangedSlot); } //! [quoting modelview_a] @@ -103,10 +104,9 @@ void MainWindow::selectionChangedSlot(const QItemSelection & /*newSelection*/, c const QModelIndex index = treeView->selectionModel()->currentIndex(); QString selectedText = index.data(Qt::DisplayRole).toString(); //find out the hierarchy level of the selected item - int hierarchyLevel=1; + int hierarchyLevel = 1; QModelIndex seekRoot = index; - while(seekRoot.parent() != QModelIndex()) - { + while (seekRoot.parent() != QModelIndex()) { seekRoot = seekRoot.parent(); hierarchyLevel++; } diff --git a/examples/widgets/tutorials/modelview/7_selections/mainwindow.h b/examples/widgets/tutorials/modelview/7_selections/mainwindow.h index 13ca7dbc30..c9761dd3d9 100644 --- a/examples/widgets/tutorials/modelview/7_selections/mainwindow.h +++ b/examples/widgets/tutorials/modelview/7_selections/mainwindow.h @@ -51,9 +51,9 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include <QtWidgets/QMainWindow> +#include <QMainWindow> -QT_BEGIN_NAMESPACE // QT_BEGIN_NAMESPACE / QT_END_NAMESPACE are not needed in Qt user code +QT_BEGIN_NAMESPACE class QTreeView; //forward declarations class QStandardItemModel; class QItemSelection; @@ -67,7 +67,7 @@ private: QTreeView *treeView; QStandardItemModel *standardModel; private slots: - void selectionChangedSlot(const QItemSelection & newSelection, const QItemSelection & oldSelection); + void selectionChangedSlot(const QItemSelection &newSelection, const QItemSelection &oldSelection); public: MainWindow(QWidget *parent = 0); }; |