You Are Here:

Community: Wiki

This page was last modified on 31 October 2009, at 15:47.

Item shifting in QlistWidget

From Forum Nokia Wiki



ID ... Creation date 17 June 2009
Platform S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition Tested on devices S60 Emulator
Category Qt for S60 Subcategory Application


Keywords (APIs, classes, methods, functions): QListWidget

Overview

This is a simple application showing the shifting of the item from one list to another.After pressing the pushbutton it is checked for any selection of item,if no item is selected then a messagebox appear showing the message to select one item.

Item with current selected row is removed from first list and moved to other list as well as the moved item is deleted form the first list.

Preconditions

Example

Note:Please select item before moving.

How to delete item from current row

int a=ui->list2->currentRow();
delete ui->list2->takeItem(a);

Source code

Header.h

#include <QtGui/QWidget>
#include<QListView>
#include<QPushButton>
#include<QString>
#include<QMessageBox>
#include<QFocusEvent>
 
namespace Ui
{
class lisClass;
}
 
class lis : public QWidget
{
Q_OBJECT
 
public:
lis(QWidget *parent = 0);
~lis();
 
private:
Ui::lisClass *ui;
 
private slots:
 
 
void on_but2_clicked();
void on_but1_clicked();
};
 
#endif // LIS_H

CPP File

#include "lis.h"
#include "ui_lis.h"
 
lis::lis(QWidget *parent)
: QWidget(parent), ui(new Ui::lisClass)
{
ui->setupUi(this);
ui->list1->addItem("Nokia N97");
ui->list1->addItem("Nokia N96");
ui->list1->addItem("Nokia N95");
ui->list1->addItem("Nokia 6630");
ui->list2->addItem("Symbian");
ui->list2->addItem("QT for S60");
ui->list2->addItem("WRT");
ui->list2->addItem("Python");
}
 
lis::~lis()
{
delete ui;
}
 
 
void lis::on_but1_clicked()
{
 
if(ui->list1->currentItem()==0)
{
QMessageBox *msg=new QMessageBox();
msg->setText("Please select one item");
QPushButton *button=new QPushButton();
msg->addButton("ok",QMessageBox::AcceptRole);
msg->show();
ui->but1->setFocus();
 
}
else
{
QString str= ui->list1->currentItem()->text();
int a=ui->list1->currentRow();
delete ui->list1->takeItem(a);
ui->list2->addItem(str);
ui->but1->setFocus();
}
 
}
 
void lis::on_but2_clicked()
{
if(ui->list2->currentItem()==0)
{
QMessageBox *msg=new QMessageBox();
msg->setText("Please select one item");
QPushButton *button=new QPushButton();
msg->addButton("ok",QMessageBox::AcceptRole);
msg->show();
}
else
{
QString str= ui->list2->currentItem()->text();
ui->list1->addItem(str);
int a=ui->list2->currentRow();
delete ui->list2->takeItem(a);
}
}

Screenshot

apps.ui

Image:Lis01.jpg

Image:Lis02.jpg

Image:Lis03.jpg

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fJ2ME45E5fE52SSE5fParserE5fwithE5fKE58mlX qdcZpublisherQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fidE2fc764fd1cE2d8b06E2d499aE2d9a6aE2d17c3903d5a65E2fforumE5fnokiaE5fcrawlerE5fagentX qdcZtitleQSxJ2ME45E20E52SSE20ParserE20withE20KE58mlE20E2dE20ForumE20NokiaE20WikiX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qrssZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qfnZdistributionQUxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2fX qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZupdatedQDx2008E2d10E2d02X qmarsZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ