PDA

View Full Version : Following Eclipse Integrated Plugin Tutorial -- help



trippinnik
25th June 2008, 04:31
I'm trying to learn Qt after doing most of my programming in Java. I'm working through the tutorial included under "Getting started" in Eclipse. I've gotten up to the part "Adding Items to the List Widget". Unfortunately I've got a compiler error.

#include "addressbook.h"
#include "adddialog.h"

AddressBook::AddressBook(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
}
void AddressBook::on_addButton_clicked()
{
AddDialog dialog(this);

if (dialog.exec()) {
QString name = dialog.name();
QString email = dialog.email();

if (!name.isEmpty() && !email.isEmpty()) {
QListWidgetItem *item = new QListWidgetItem(name, ui.addressList);
item->setData(Qt::UserRole, email);
ui.addressList->setCurrentItem(item);
}
}
}



AddressBook::~AddressBook()
{

}


error:
addressbook.cpp: In member function ‘void AddressBook::on_addButton_clicked()’:
addressbook.cpp:48: error: ‘QListWidgetItem’ was not declared in this scope
addressbook.cpp:48: error: ‘item’ was not declared in this scope
addressbook.cpp:48: error: expected type-specifier before ‘QListWidgetItem’
addressbook.cpp:48: error: expected `;' before ‘QListWidgetItem’
addressbook.cpp:50: error: ‘class QListView’ has no member named ‘setCurrentItem’

Not sure how to fix it. I'm using Qt-4.4.

fnmblot
25th June 2008, 16:32
Try adding

#include <QListWidgetItem>
at the top of the file.

trippinnik
26th June 2008, 04:46
Thanks for the help. Got me on the right track. I used the wrong widget... [SOLVED]