×
Namespaces

Variants
Actions

Archived:QListView with icons

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Qt Quick should be used for all UI development on mobile devices. The approach described in this article (using C++ for the Qt app UI) is deprecated.

Article Metadata
Code ExampleTested with
Devices(s): Nokia 6210 Navigator, Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 3rd Edition FP2, S60 5th Edition
Symbian
S60 5th Edition
S60 3rd Edition FP2
Article
Keywords: QListView, Icon, QStandardItemModel
Created: User:Technical writer 1 (09 Apr 2009)
Last edited: hamishwillee (11 Oct 2012)

Contents

Overview

This article explains how to use icons with QListView.

Description

The QListView class is one of the Model/View classes and is part of Qt's model/view framework. QStandardItemModel can be used to show icons and texts in QListView.


Solution

Header file

    QStandardItemModel* iStandardModel;
QListView* iListView;

.cpp file


 iListView = new QListView(this);
//Creating a standard item model
iStandardModel = new QStandardItemModel(this);
//First item
QStandardItem* item1 = new QStandardItem(QIcon("c:\\data\\Nokia- logo.bmp"),"First Item");
//Second item
QStandardItem* item2 = new QStandardItem(QIcon("c:\\data\\sample.bmp"),"Second item");
//third item without icon
QStandardItem* item3 = new QStandardItem("Without icon item");
//Appending the items into model
iStandardModel->appendRow(item1);
iStandardModel->appendRow(item2);
iStandardModel->appendRow(item3);
//Setting the icon size
iListView->setIconSize(QSize(40,30));
//Setting the model
iListView->setModel(iStandardModel);
//Setting listview geometry
iListView->setGeometry(QRect(0,0,240,320));

Sample application

File:QListViewIconMode.zip

This page was last modified on 11 October 2012, at 04:14.
132 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×