Hi,

I'm new to using Qt and I'm having a small problem, when I try to execute my program I'm getting this error message

Unhandled exception at 0x671e26f1 (QtCored4.dll) in practice.exe: 0xC0000005: Access violation reading location 0x00000004.

and it's telling me it is in qobject.cpp (which obviously can't be right).

Qt Code:
  1. #include <QtGui>
  2. #include "practice.h"
  3.  
  4. practice::practice(QWidget *parent, Qt::WFlags flags)
  5. : QMainWindow(parent, flags)
  6. {
  7. ui.setupUi(this);
  8. connect(pushButton, SIGNAL(clicked()), this, SLOT(addItem()));
  9. connect(pushButton_2, SIGNAL(clicked()), this, SLOT(removeItem()));
  10. connect(pushButton_3, SIGNAL(clicked()), this, SLOT(quit()));
  11. }
  12. void practice::addItem()
  13. {
  14. if( lineEdit->text().length() > 0 )
  15. {
  16. listWidget->insertItem(1, lineEdit->text() );
  17. lineEdit->clear();
  18. }
  19.  
  20. lineEdit->setFocus();
  21. }
  22.  
  23. void practice::removeItem()
  24. {
  25. delete listWidget->takeItem(1);
  26. }
  27.  
  28.  
  29. void practice::init()
  30. {
  31. listWidget->clear();
  32. lineEdit->setFocus();
  33. }
To copy to clipboard, switch view to plain text mode 

Any ideas from anyone? Also while I'm here, can anyone explain to me the correct way to access mimeData()? I was hoping to do a check for an empty list widget with it and then only if the list wasn't empty could you perform the remove, but I can't quite figure out the syntax. Thanks.