1 Attachment(s)
how to add item in a list widget on clicking of a pushbutton
hi all
my form appears like this(attachment)...
nw i want when i enter any item_name in a line edit and then i click the pushbutton i.e enter item
then that string of line_edit come in list widget box
n even tell me the procedure for remove item(highlightened) from list widget box....
plz do reply as soon as possible..
thanks in advance
Re: how to add item in a list widget on clicking of a pushbutton
You can't do these from within Designer. Use either multiple or single inheritance approach and create custom slots for doing those tasks.
Code:
connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(newItem()));
void MyForm::newItem()
{
ui.listWidget->addItem(ui.lineEdit->text());
}
Re: how to add item in a list widget on clicking of a pushbutton
thanks alot...
can u further tell how to remove item from list widget.....on clicking of pushbutton
n one thing more in previous query...when we click the pushbutton then line edit text item inserted in list as well as line_edit should be clear n ready to get the next item (i.e insertion for next item)......
Re: how to add item in a list widget on clicking of a pushbutton
Quote:
Originally Posted by
jyoti
can u further tell how to remove item from list widget.....on clicking of pushbutton
In the same way, just create a custom slot connected to the button's clicked() signal and do the task by hand:
Code:
connect(ui.someButton, SIGNAL(clicked()), this, SLOT(deleteItems()));
void MyForm::deleteItems()
{
qDeleteAll(ui.listWidget->selectedItems());
}
Quote:
Originally Posted by
jyoti
n one thing more in previous query...when we click the pushbutton then line edit text item inserted in list as well as line_edit should be clear n ready to get the next item (i.e insertion for next item)......
QLineEdit::clear()
Code:
ui.lineEdit->clear();
Re: how to add item in a list widget on clicking of a pushbutton
Before that read the docs!
All the questions you asked, simply proves that you have not read the docs properly.
Next time, you post, Only thing you need to do is to state the requirements
We will do the job for you.
Re: how to add item in a list widget on clicking of a pushbutton
i use the same codes but it dont work.
#include "mainwindow.h"
#include <Qt\qlistwidget.h>
#include <Qt\qlineedit.h>
#include <Qt\qpushbutton.h>
#include <Qt\qlinkedlist.h>
mainwindow::mainwindow(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
setFixedSize(300,300);
int Top = 0;
liste = new QListWidget(this);
liste->setGeometry(10,10,80,200);
line = new QLineEdit(this);
line->setGeometry(100,10,80,20);
m_buton = new QPushButton("add",this);
m_buton->setGeometry(100,50,80,20);
QObject::connect(m_buton,SIGNAL(clicked()),this,SL OT(additem()));
}
void mainwindow::additem()
{
liste->addItem(new QListWidgetItem(line->text()));
}
anapencere::~anapencere()
{
}
please help where is the mistake ????????????
Re: how to add item in a list widget on clicking of a pushbutton
If you want to delete an item from the list, just select it and click on push button, where it takes the index of the currently selected item, and just delete it.
It is very simple. Just refer the guide. http://doc.qt.digia.com/qt/qlistwidg...urrentRow-prop
Re: how to add item in a list widget on clicking of a pushbutton
Quote:
Originally Posted by
thekiller
i use the same codes but it dont work.
#include "mainwindow.h"
#include <Qt\qlistwidget.h>
#include <Qt\qlineedit.h>
#include <Qt\qpushbutton.h>
<SNIP>
please help where is the mistake ????????????
1 - use code tags
2 - qt includes should look like
Code:
#include <QLineEdit>
3 - please define "don't work".
4 - additem is a slot? Show you header! use code tags, please!
3 Attachment(s)
how to append data items from a list widget to another list widget using pushbutton
hi all
my form appears like this(attachment)..
and i want to append data items from a list widget to another list widget using qpushbutton.Tell me the procedure how to do it. How i can use signal &slot to complete this task.
Also please tell me the procedure for remove item(highlightened) from list widget box....
plz do reply as soon as possible..
thanks in advance