diff options
Diffstat (limited to 'examples/tutorials/modelview/6_treeview')
-rwxr-xr-x[-rw-r--r--] | examples/tutorials/modelview/6_treeview/6_treeview.pro | 12 | ||||
-rwxr-xr-x[-rw-r--r--] | examples/tutorials/modelview/6_treeview/main.cpp | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | examples/tutorials/modelview/6_treeview/mainwindow.cpp (renamed from examples/tutorials/modelview/6_treeview/modelview.cpp) | 24 | ||||
-rwxr-xr-x[-rw-r--r--] | examples/tutorials/modelview/6_treeview/mainwindow.h (renamed from examples/tutorials/modelview/6_treeview/modelview.h) | 19 |
4 files changed, 33 insertions, 26 deletions
diff --git a/examples/tutorials/modelview/6_treeview/6_treeview.pro b/examples/tutorials/modelview/6_treeview/6_treeview.pro index 6d078be..e79ef20 100644..100755 --- a/examples/tutorials/modelview/6_treeview/6_treeview.pro +++ b/examples/tutorials/modelview/6_treeview/6_treeview.pro @@ -1,5 +1,13 @@ TARGET = mv_tree TEMPLATE = app SOURCES += main.cpp \ - modelview.cpp -HEADERS += modelview.h + mainwindow.cpp +HEADERS += mainwindow.h + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/6_treeview +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 6_treeview.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/modelview/6_treeview +INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tutorials/modelview/6_treeview/main.cpp b/examples/tutorials/modelview/6_treeview/main.cpp index 7be212e..59e82ef 100644..100755 --- a/examples/tutorials/modelview/6_treeview/main.cpp +++ b/examples/tutorials/modelview/6_treeview/main.cpp @@ -39,12 +39,12 @@ ****************************************************************************/ #include <QtGui/QApplication> -#include "modelview.h" +#include "mainwindow.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); - ModelView w; + MainWindow w; w.show(); return a.exec(); } diff --git a/examples/tutorials/modelview/6_treeview/modelview.cpp b/examples/tutorials/modelview/6_treeview/mainwindow.cpp index 772dbdd..a105232 100644..100755 --- a/examples/tutorials/modelview/6_treeview/modelview.cpp +++ b/examples/tutorials/modelview/6_treeview/mainwindow.cpp @@ -43,40 +43,40 @@ #include <QTreeView> #include <QStandardItemModel> #include <QStandardItem> -#include "modelview.h" +#include "mainwindow.h" const int ROWS = 2; const int COLUMNS = 3; -ModelView::ModelView(QWidget *parent) +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { treeView = new QTreeView(this); setCentralWidget(treeView); standardModel = new QStandardItemModel ; - QList<QStandardItem *> preparedColumn =prepareColumn("first", "second", "third"); + QList<QStandardItem *> preparedRow =prepareRow("first", "second", "third"); QStandardItem *item = standardModel->invisibleRootItem(); // adding a row to the invisible root item produces a root element - item->appendRow(preparedColumn); + item->appendRow(preparedRow); - QList<QStandardItem *> secondRow =prepareColumn("111", "222", "333"); + QList<QStandardItem *> secondRow =prepareRow("111", "222", "333"); // adding a row to an item starts a subtree - preparedColumn.first()->appendRow(secondRow); + preparedRow.first()->appendRow(secondRow); treeView->setModel(standardModel); treeView->expandAll(); } -QList<QStandardItem *> ModelView::prepareColumn(const QString &first, +QList<QStandardItem *> MainWindow::prepareRow(const QString &first, const QString &second, const QString &third) { - QList<QStandardItem *> colItems; - colItems << new QStandardItem(first); - colItems << new QStandardItem(second); - colItems << new QStandardItem(third); - return colItems; + QList<QStandardItem *> rowItems; + rowItems << new QStandardItem(first); + rowItems << new QStandardItem(second); + rowItems << new QStandardItem(third); + return rowItems; } //! [Quoting ModelView Tutorial] diff --git a/examples/tutorials/modelview/6_treeview/modelview.h b/examples/tutorials/modelview/6_treeview/mainwindow.h index 55f3470..fb8de79 100644..100755 --- a/examples/tutorials/modelview/6_treeview/modelview.h +++ b/examples/tutorials/modelview/6_treeview/mainwindow.h @@ -38,28 +38,27 @@ ** ****************************************************************************/ -#ifndef MODELVIEW_H -#define MODELVIEW_H +#ifndef MAINWINDOW_H +#define MAINWINDOW_H #include <QtGui/QMainWindow> -QT_BEGIN_NAMESPACE class QTreeView; //forward declaration class QStandardItemModel; class QStandardItem; -QT_END_NAMESPACE -class ModelView : public QMainWindow + +class MainWindow : public QMainWindow { Q_OBJECT private: QTreeView *treeView; QStandardItemModel *standardModel; - QList<QStandardItem *> prepareColumn(const QString &first, - const QString &second, - const QString &third); + QList<QStandardItem *> prepareRow( const QString &first, + const QString &second, + const QString &third ); public: - ModelView(QWidget *parent = 0); + MainWindow(QWidget *parent = 0); }; -#endif // MODELVIEW_H +#endif // MAINWINDOW_H |