Results 1 to 8 of 8

Thread: QListWidget-problem

  1. #1
    Join Date
    Mar 2006
    Location
    Hyderabad
    Posts
    69
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default QListWidget-problem

    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,QListWidgetIt em::Type);
    new QListWidgetItem(tr("TWO"),listwidget,QListWidgetIt em::Type);
    new QListWidgetItem(tr("THREE"),listwidget,QListWidget Item::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

  2. #2
    Join Date
    Feb 2006
    Location
    Boulder, Colorado, USA
    Posts
    63
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget-problem

    First off, the proper include file should be #include<QListWidget> and why are you creating heap objects with no pointer?

  3. #3
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget-problem

    Are your QTDIR path is correct?
    a life without programming is like an empty bottle

  4. #4
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget-problem

    Quote Originally Posted by jrideout
    First off, the proper include file should be #include<QListWidget>?
    Its Qt4 style , for Qt3 #inlude<qlistwidget.h> is right
    a life without programming is like an empty bottle

  5. #5
    Join Date
    Feb 2006
    Location
    Boulder, Colorado, USA
    Posts
    63
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget-problem

    Is there a QListWidget for qt3?

  6. #6
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget-problem

    Quote Originally Posted by jrideout
    Is there a QListWidget for qt3?
    no of course its my missing
    a life without programming is like an empty bottle

  7. #7
    Join Date
    Feb 2006
    Location
    Boulder, Colorado, USA
    Posts
    63
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget-problem

    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.

  8. #8
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget-problem

    Check your QTDIR.

    Also are you using Qt3 or Qt4? it's unclear from your post.
    Last edited by Chicken Blood Machine; 7th April 2006 at 18:52.
    Save yourself some pain. Learn C++ before learning Qt.

Similar Threads

  1. QListWidget SIGNAL Problem
    By skuda in forum Qt Programming
    Replies: 19
    Last Post: 28th October 2009, 14:42
  2. QListWidget - stylesheet problem
    By febil in forum Qt Programming
    Replies: 3
    Last Post: 23rd February 2009, 16:44
  3. Problem with events changing behavior of QListWidget
    By riklaunim in forum Qt Programming
    Replies: 10
    Last Post: 22nd December 2008, 19:10
  4. The problem with the display of QListWidget
    By whyisosad in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2008, 19:41
  5. QListWidget Problem
    By pmabie in forum Qt Programming
    Replies: 1
    Last Post: 7th October 2007, 06:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.