Results 1 to 10 of 10

Thread: QtListView

  1. #1
    Join Date
    Mar 2011
    Posts
    33
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default QtListView

    Hello,

    I'm trying to make a listview like this one

    URL removed

    You can see

    Colum,Colum,Colum
    45 45 45

    or what numbers, I would like to make it in Qt, I don't know how many items so I've to make a function which do this do. As last thing I would like to have grid lines, so it's easy to see what belongs to what.

    I googled and found out that QListView don't supports more than 1 column, but QtTableView is with a 1 for the item etc.

    thanks for reading,
    Last edited by wysota; 20th March 2011 at 17:43. Reason: removed URL

  2. #2
    Join Date
    Mar 2011
    Posts
    33
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QtListView

    Sorry for the picture, not that important.

    But I found out that I should use a TableView. Or TableWidget, what is the real difference between those?

    I also found out that I need rows to add items, I would like to have none, ani ideas?

  3. #3
    Join Date
    Nov 2010
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QtListView

    The TableView requires you to input your own data model as specified by the model/view framework. This is overkill for your application probably. The TableWidget provides a nice simple way to construct a table with a default model.

    About a quarter of the way down this page is a good example. Here, you create QTableWidgetItems and add them to the TableWidget. It's pretty simple and fast.

    Order Form Example
    Last edited by wysota; 20th March 2011 at 23:00.

  4. #4
    Join Date
    Mar 2011
    Posts
    33
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QtListView

    thanks, that works.

    Now I'm trying to add item, but I've to make a row, is it possible to make the row invisible or just left out of it.

    Or can I use the row just as value of the first column?

    EDIT: seems only 1 row can I've specific item, is it possible to have more?
    Last edited by Nazgul; 20th March 2011 at 22:35.

  5. #5
    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: QtListView

    Quote Originally Posted by Nazgul View Post
    Now I'm trying to add item, but I've to make a row, is it possible to make the row invisible or just left out of it.
    Or can I use the row just as value of the first column?
    Forgive me, but what is the point of adding a row to the table if you only want to hide it? You can hide a row in the view with QTableView::setRowHidden().

    A row is a set of columns. How do you propose to put a set of columns into a single column?

    Perhaps you mean a row number? You can use the vertical header that is provided by default, which displays row numbers, or provide your own header values (including an empty string).
    EDIT: seems only 1 row can I've specific item, is it possible to have more?
    I have no idea what you mean here. You can have as many rows as memory will allow. Every cell of every row can have whatever value you would like. Every header for a row (column) can have whatever value you would like.

  6. #6
    Join Date
    Mar 2011
    Posts
    33
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QtListView

    Quote Originally Posted by ChrisW67 View Post
    Forgive me, but what is the point of adding a row to the table if you only want to hide it? You can hide a row in the view with QTableView::setRowHidden().

    A row is a set of columns. How do you propose to put a set of columns into a single column?

    Perhaps you mean a row number? You can use the vertical header that is provided by default, which displays row numbers, or provide your own header values (including an empty string).

    I have no idea what you mean here. You can have as many rows as memory will allow. Every cell of every row can have whatever value you would like. Every header for a row (column) can have whatever value you would like.
    Sorry for my bad english + not well telling.

    Anyways I get this error in debug mode.

    QTableWidget: cannot insert an item that is already owned by another QTableWidget
    That is what i ment with my edit.

    In win32 you could use CreateWindowEx() to create a listview, then add items to it, there were no rows

    _ __| colum1 colum2
    row1
    row2

    // I would like to get rid of the row things before, but keep the value from colum1 and colum2 there.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtListView

    Qt Code:
    1. tableWidget->verticalHeader()->hide();
    To copy to clipboard, switch view to plain text mode 
    Is that what you want?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. The following user says thank you to wysota for this useful post:

    Nazgul (20th March 2011)

  9. #8
    Join Date
    Mar 2011
    Posts
    33
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QtListView

    Quote Originally Posted by wysota View Post
    Qt Code:
    1. tableWidget->verticalHeader()->hide();
    To copy to clipboard, switch view to plain text mode 
    Is that what you want?
    thanks that worked

    Now gotta find a solution to that other problem, ideas?

  10. #9
    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: QtListView

    The other warning message is probably coming from using the same QTableWidgetItem several times in calls to setItem(). If you want to add three cells each containing the same value you should create three separate QTableWidgetItems with the same value and add those.

    If that is not what you are doing then you will need to show the offending code.

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

    Nazgul (21st March 2011)

  12. #10
    Join Date
    Mar 2011
    Posts
    33
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QtListView

    Ye, you're right (again), thanks I used twice the QTableWidgetItem.

    Could be closes now.

Similar Threads

  1. QtListView::connect
    By John-P in forum Qt Programming
    Replies: 8
    Last Post: 28th January 2010, 13:03

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.