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.
Qt Code:
  1. #include "addressbook.h"
  2. #include "adddialog.h"
  3.  
  4. AddressBook::AddressBook(QWidget *parent)
  5. : QWidget(parent)
  6. {
  7. ui.setupUi(this);
  8. }
  9. void AddressBook::on_addButton_clicked()
  10. {
  11. AddDialog dialog(this);
  12.  
  13. if (dialog.exec()) {
  14. QString name = dialog.name();
  15. QString email = dialog.email();
  16.  
  17. if (!name.isEmpty() && !email.isEmpty()) {
  18. QListWidgetItem *item = new QListWidgetItem(name, ui.addressList);
  19. item->setData(Qt::UserRole, email);
  20. ui.addressList->setCurrentItem(item);
  21. }
  22. }
  23. }
  24.  
  25.  
  26.  
  27. AddressBook::~AddressBook()
  28. {
  29.  
  30. }
To copy to clipboard, switch view to plain text mode 

error:
addressbook.cpp: In member function ‘void AddressBook:n_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.