Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Archived:How to use QListWidget and QListWidgetItem

From 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 (based on QWidget) is deprecated.

This example shows how to create simple lists using a QListWidget populated withQListWidgetItems. QListWidget is a convenience class that provides a list view similar to the one supplied by QListView, but with a classic item-based interface for adding and removing items.

Article Metadata
Tested with
Devices(s): Qt Creator IDE & S60 Emulator
Platform(s): S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition
Platform Security
Signing Required: Self-Signed
Capabilities: None
Keywords: QListWidget,QListItemWidget
Created: mind_freak (14 Mar 2009)
Last edited: hamishwillee (11 Oct 2012)


Various Function

  • If this property is true, sorting is enabled for the list; if the property is false, sorting is not enabled. The default value is false.

Source Code

#include <QApplication>
#include <QWidget>
#include <QHBoxLayout>
#include <QListWidget>
#include <QListWidgetItem>
int main(int argc, char *argv[])
QApplication a(argc, argv);
QListWidget *listWidget = new QListWidget();
listWidget->addItem(new QListWidgetItem("Oak"));
listWidget->addItem(new QListWidgetItem("Banana"));
listWidget->addItem(new QListWidgetItem("Apple"));
listWidget->addItem(new QListWidgetItem("Orange"));
listWidget->addItem(new QListWidgetItem("Grapes"));
listWidget->addItem(new QListWidgetItem("Jayesh"));
listWidget->addItem(new QListWidgetItem("Pineapple"));
listWidget->addItem(new QListWidgetItem("GROUNDNUT"));
listWidget->addItem(new QListWidgetItem("Sugarcane"));
listWidget->addItem(new QListWidgetItem("Coconut"));
listWidget->addItem(new QListWidgetItem("Remote"));
listWidget->addItem(new QListWidgetItem("Mango"));
QHBoxLayout *layout = new QHBoxLayout();
QMainWindow w;
w.setStyleSheet("* { background-color:rgb(199,147,88); padding: 7px ; color:rgb(255,255,255)}");
return a.exec();



Icon listview

list=new QListWidget();
item1=new QListWidgetItem(QIcon("D:\\Blue hills.PNG"),"BlueHills",list);
item2=new QListWidgetItem(QIcon("D:\\Sunset.PNG"),"Sunset",list);
item3=new QListWidgetItem(QIcon("D:\\Water lilies.PNG"),"Water lilies",list);
item4=new QListWidgetItem(QIcon("D:\\Winter.PNG"),"Winter",list);

screen shot


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