×
Namespaces

Variants
Actions

Archived:How to select multiple items with QListWidget

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

The QListWidget class provides an item-based list widget that contains a number of QListWidgetItems. This code snippet shows how we can touch and select multiple items using this list widget.

Article Metadata
Code ExampleTested with
Devices(s): Nokia C7-00 with Belle Firmware
Compatibility
Platform(s):
Symbian
Nokia Belle
Article
Created: mahbub_s60 (20 Dec 2011)
Last edited: hamishwillee (11 Oct 2012)

What needs to be done to enable multiple selection

The selectionMode() of a list widget determines how many of the items in the list can be selected at the same time, and whether complex selections of items can be created. This can be set with the setSelectionMode() function.

setSelectionMode(QAbstractItemView::MultiSelection );

We associate itemClicked signal with corresponding slot.

connect(this, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(HandleItem()));

When an item is clicked then the HandleItem() slot is called. HandleItem() looks like this:

void ContentTab::HandleItem()
{
currentItem()->setSelected (!currentItem()->isSelected());
setCurrentRow(currentRow(), QItemSelectionModel::Toggle );
}


Sample Example

Sample code can be downloaded from the following zip file, It was tested with C7 Belle SW.

Multiselection.png

Download the example for Belle: File:ListWidgetMulti.zip

This page was last modified on 11 October 2012, at 04:14.
183 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.

×