PDA

View Full Version : QListWidget-problem



Sarma
7th April 2006, 13:34
Hi all,
I am using QListWidget (as per my problem requirement).
Here is my code:
-------------

#include<qlistwidget.h>
#include<qlistwidgetitem.h>

listwidget=new QListWidget(this); //this is the user defined widget extending QWidget to which listwidget is added

new QListWidgetItem(tr("ONE"),listwidget,QListWidgetItem::Type);
new QListWidgetItem(tr("TWO"),listwidget,QListWidgetItem::Type);
new QListWidgetItem(tr("THREE"),listwidget,QListWidgetItem::Type);

Its giving me following errors:

"filter.cpp", line 11: Error: Could not open include file <qlistwidget.h>.
"filter.cpp", line 12: Error: Could not open include file <qlistwidgetitem.h>.
"filter.cpp", line 36: Error: The type "QListWidget" is incomplete.
"filter.cpp", line 37: Error: Type name expected instead of "QListWidgetItem".
"filter.cpp", line 37: Error: QListWidgetItem is not defined.
"filter.cpp", line 37: Error: Type is not defined.
"filter.cpp", line 37: Error: Too many initializers for int.
"filter.cpp", line 37: Error: Cannot use QString to initialize int.
"filter.cpp", line 38: Error: Type name expected instead of "QListWidgetItem".
"filter.cpp", line 38: Error: QListWidgetItem is not defined.
"filter.cpp", line 38: Error: Type is not defined.
"filter.cpp", line 38: Error: Too many initializers for int.
"filter.cpp", line 38: Error: Cannot use QString to initialize int.
"filter.cpp", line 39: Error: Type name expected instead of "QListWidgetItem".
"filter.cpp", line 39: Error: QListWidgetItem is not defined.
"filter.cpp", line 39: Error: Type is not defined.
"filter.cpp", line 39: Error: Too many initializers for int.
"filter.cpp", line 39: Error: Cannot use QString to initialize int.

plz tell me the reason.I am QT begineer ,so my queries may be primitive but plz help me.

waiting for reply
thanks in advance
Sarma

jrideout
7th April 2006, 13:39
First off, the proper include file should be #include<QListWidget> and why are you creating heap objects with no pointer?

zlatko
7th April 2006, 13:39
Are your QTDIR path is correct?

zlatko
7th April 2006, 13:41
First off, the proper include file should be #include<QListWidget>?

Its Qt4 style , for Qt3 #inlude<qlistwidget.h> is right

jrideout
7th April 2006, 13:44
Is there a QListWidget for qt3?

zlatko
7th April 2006, 13:46
Is there a QListWidget for qt3?
:D no of course its my missing

jrideout
7th April 2006, 13:49
Also, as for my scoffing on just creating the heap objects, I realized this is ok as long as the parent is set. Qt holds the pointer in the parent and will destroy QListWidgetItem when the QListWidget is destroyed.

Chicken Blood Machine
7th April 2006, 18:49
Check your QTDIR.

Also are you using Qt3 or Qt4? it's unclear from your post.