Results 1 to 7 of 7

Thread: problem with QListView

  1. #1
    Join Date
    Dec 2010
    Posts
    33
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default problem with QListView

    i have written the following code, for QListView, and now i want to add data to the QListView. But the addColumn method is giving an error,

    'addColumn' : is not a member of 'QListView'

    Also, there is a "syntax error : identifier QListViewItem"

    this is my code:
    QListView *list = new QListView(this);
    list->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn) ;
    list->addColumn("name");
    list->setAllColumnsShowFocus(true);
    new QListViewItem(list,"myname1");


    I have included qlistview.h..
    Last edited by penny; 3rd January 2011 at 09:33.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: problem with QListView

    'addColumn' : is not a member of 'QListView'
    Q3ListView::addColumn(), Q3ListView::setAllColumnsShowFocus() and Q3ListViewItem are part of the Qt4 support for porting from Qt3. Looks like you have code for Qt3 but a Qt4 dev environment. Are you programming for Qt3 or Qt4?

    Please use [code] tags around your code snippets. (You can edit your first post to add them)

  3. The following user says thank you to ChrisW67 for this useful post:

    penny (3rd January 2011)

  4. #3
    Join Date
    Dec 2010
    Posts
    33
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with QListView

    I'm using Qt4.. So which file do i need to include? The qlistview.h file doesn't have definitions of addColumn and setAllColumnsShowFocus.

  5. #4
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: problem with QListView

    hi,
    u want one column or more columns?
    Bala

  6. #5
    Join Date
    Dec 2010
    Posts
    33
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with QListView

    I want only one column

  7. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with QListView

    What you have will only work on Qt3 (or the QT3 support for QT4). You will need to port your code to QT4.

  8. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: problem with QListView

    You need to use QListView or QListWidget. The way these are populated has changed since Qt3 though, so you will have to modify your code to match Qt4.

    If you continue to use QListView then you need to create a model of some sort to provide the data. This model is where you will find the equivalent of addColumn(). If you use QListWidget then the API is a little closer to what your code is expecting.

    Either way you must read "Model/View Programming" in Assistant.

Similar Threads

  1. QListView stylesheet problem
    By JPNaude in forum Qt Programming
    Replies: 9
    Last Post: 15th November 2010, 14:15
  2. QListview Problem
    By grsandeep85 in forum Qt Programming
    Replies: 0
    Last Post: 17th August 2009, 10:55
  3. QlistView problem
    By grsandeep85 in forum Qt Programming
    Replies: 0
    Last Post: 7th August 2009, 06:19
  4. QDialog / QListView problem
    By harakiri in forum Qt Programming
    Replies: 1
    Last Post: 10th July 2007, 18:31
  5. Problem with doubleClicked in QListView with Qt 4.2.2
    By gauravagarwal in forum Qt Programming
    Replies: 1
    Last Post: 3rd May 2007, 10:28

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.