Qt 5.10 Book Examples
chapter12
SelectionSharing
main.cpp
Go to the documentation of this file.
1
// ======================================================================
2
// main.cpp
3
// ======================================================================
4
// This file is a part of the book
5
// "Qt 5.10 Professional programming with C++"
6
// http://qt-book.com
7
// ======================================================================
8
// Copyright (c) 2017 by Max Schlee
9
// ======================================================================
10
11
#include <QtWidgets>
12
13
// ----------------------------------------------------------------------
14
int
main
(
int
argc,
char
** argv)
15
{
16
QApplication app(argc, argv);
17
QWidget wgt;
18
19
QStringListModel model;
20
model.setStringList(QStringList() <<
"Item1"
<<
"Item2"
<<
"Item3"
);
21
22
QTreeView* pTreeView =
new
QTreeView;
23
pTreeView->setModel(&model);
24
25
QListView* pListView =
new
QListView;
26
pListView->setModel(&model);
27
28
QTableView* pTableView =
new
QTableView;
29
pTableView->setModel(&model);
30
31
QItemSelectionModel selection(&model);
32
pTreeView->setSelectionModel(&selection);
33
pListView->setSelectionModel(&selection);
34
pTableView->setSelectionModel(&selection);
35
36
//Layout setup
37
QHBoxLayout* phbxLayout =
new
QHBoxLayout;
38
phbxLayout->addWidget(pTreeView);
39
phbxLayout->addWidget(pListView);
40
phbxLayout->addWidget(pTableView);
41
wgt.setLayout(phbxLayout);
42
43
wgt.show();
44
45
return
app.exec();
46
}
47
main
int main(int argc, char **argv)
Definition:
main.cpp:15
Generated by
1.8.14