Doc: Compile standard item model snippets

Fix minor issues (e.g. whitespace, missing semi-colon) in passing.

Done-with: Nico Vertriest <nico.vertriest@qt.io>
Task-number: QTBUG-81486
Change-Id: I46301d37112bddcd38dbff9940d0c22eaae74208
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
This commit is contained in:
Paul Wicking 2020-08-25 12:41:01 +02:00
parent ebabbd0264
commit 4845a0de2e
2 changed files with 31 additions and 1 deletions

View File

@ -12,4 +12,5 @@ SOURCES = \
src_gui_image_qimagewriter.cpp \
src_gui_image_qmovie.cpp \
src_gui_image_qpixmapcache.cpp \
src_gui_image_qpixmap.cpp
src_gui_image_qpixmap.cpp \
src_gui_itemviews_qstandarditemmodel.cpp

View File

@ -47,6 +47,20 @@
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QStandardItemModel>
#include <QTreeView>
#include <QWidget>
namespace src_gui_itemviews_qstandarditemmodel {
struct MyWidget : public QWidget
{
void wrapper2();
void clicked(const QModelIndex &index);
QModelIndex index() { return QModelIndex(); }
QStandardItemModel *myStandardItemModel;
};
void wrapper0() {
//! [0]
QStandardItemModel model(4, 4);
@ -58,6 +72,10 @@ for (int row = 0; row < model.rowCount(); ++row) {
}
//! [0]
} // wrapper0
void wrapper1() {
//! [1]
QStandardItemModel model;
@ -69,7 +87,10 @@ for (int i = 0; i < 4; ++i) {
}
//! [1]
} // wrapper1
void MyWidget::wrapper2() {
//! [2]
QTreeView *treeView = new QTreeView(this);
treeView->setModel(myStandardItemModel);
@ -77,6 +98,8 @@ connect(treeView, &QTreeView::clicked,
this, &MyWidget::clicked);
//! [2]
} // wrapper2
//! [3]
void MyWidget::clicked(const QModelIndex &index)
@ -87,6 +110,12 @@ void MyWidget::clicked(const QModelIndex &index)
//! [3]
void wrapper3() {
QTreeView *treeView = nullptr;
MyWidget *item = nullptr;
//! [4]
treeView->scrollTo(item->index());
//! [4]
} // wrapper3
} // src_gui_itemviews_qstandarditemmodel