| 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 |
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.
Note:Please select item before moving.
int a=ui->list2->currentRow();
delete ui->list2->takeItem(a);
#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
#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);
}
}
No related wiki articles found