PDA

View Full Version : array list!



maider
27th July 2009, 11:13
good morning!

I have to do a list of char datas.

The code that I'm using is:


archivo::archivo(QWidget *parent)
: QWidget(parent)
{

QVBoxLayout *box = new QVBoxLayout;
QListView *list = new QListView;
list<<"maider"<<"peter"<<"maider";

list->show();

}


why can't i see the list? In qt4 to do an array they use QVector fuction. Which function can I use in QT3?my version is: Version: 3.4.1

wagmare
27th July 2009, 11:39
yes i want to learn about this thing QListView

Lykurg
27th July 2009, 11:59
QListView

I think you need QListWidget, an populate it through a QStringList. See QListWidget::addItems().

maider
27th July 2009, 13:13
why not with QListView?

I can't do with strigs i have to do with arrays

wagmare
27th July 2009, 13:34
the problem is in

list<<"maider"<<"peter"<<"maider";

u have to add QString or any other in QListView as in docs

QListWidgetItem *newItem = new QListWidgetItem;
newItem->setText("maider");
listWidget->insertItem(row, newItem);

wysota
27th July 2009, 14:54
Guys, this issue is related to Qt3, not Qt4... There is no QListWidget in Qt3.

Lykurg
27th July 2009, 16:27
Guys, this issue is related to Qt3, not Qt4...
:eek: Qt3, someone is still working with Qt3, my brain substitutes 4.3 (and with "Version: 3.4.1" that can happen:)). Ok, then:

QListView has no << operator, you have to set up the column count and add QListViewItems. Something like that:

QListView *table;
table->addColumn( "Names" );
new QListViewItem( table, "maider" ); // in your case loop your array...
new QListViewItem( table, "Peter" );
new QListViewItem( table, "maider" );