Qt 5.10 Book Examples
chapter11
IconMode
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
QListWidget lwg;
18
QListWidgetItem* pitem = 0;
19
QStringList lst;
20
21
lwg.setIconSize(QSize(48, 48));
22
lwg.setSelectionMode(QAbstractItemView::MultiSelection);
23
lwg.setViewMode(QListView::IconMode);
24
lst <<
"Linux"
<<
"Windows"
<<
"MacOSX"
<<
"Android"
;
25
foreach
(QString str, lst) {
26
pitem =
new
QListWidgetItem(str, &lwg);
27
pitem->setIcon(QPixmap(
":/"
+ str +
".jpg"
));
28
pitem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
29
Qt::ItemIsEditable | Qt::ItemIsDragEnabled);
30
31
}
32
lwg.resize(150, 150);
33
lwg.show();
34
35
return
app.exec();
36
}
main
int main(int argc, char **argv)
Definition:
main.cpp:15
Generated by
1.8.14