Results 1 to 4 of 4

Thread: QTableWidget or QListWidget

  1. #1
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTableWidget or QListWidget

    I have a question about which one I should use for my project.

    Essentially I am going to obtain a QStringList of tokened data.
    When I iterate through this list I am going to tokenize that string into 3 strings.

    Graphically speeking, I basically want a list with three columns.
    Each iteration adds a row, the column data is what is tokenized from the string.

    I have used the QTableWidget so far. I am creating headings for the columns... something I don't think QListWidget will do. I need those. BUT, QTableWidget seems to be "cell" oriented. When I click on a cell, I want the row highlighted. This makes me wonder if it needs to be a QListWidget instead.

    Do you guys have any good advice on what I should do?

    Essentially when you select a row, there will be a number of functions that you can call... like pressing a button that will delete that row or perform various routines pertaining to the database record represented by that row.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget or QListWidget

    Just set selectionBehavior property to QAbstractItemView::SelectRows.

  3. #3
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget or QListWidget

    Thanks a lot Jacek for that advice. I didn't see that option.

    I have one last question... if I set my column size to 3, for example, can I store data about that row in column 4?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget or QListWidget

    Quote Originally Posted by bpetty View Post
    if I set my column size to 3, for example, can I store data about that row in column 4?
    Yes, but you'll have to hide that fourth column. Better use QTableView and a custom model --- you'll have more control over the data.

Similar Threads

  1. QTableWidget issues
    By Djony in forum Qt Programming
    Replies: 42
    Last Post: 19th December 2006, 23:27
  2. print QTableWidget
    By chak_med in forum Qt Programming
    Replies: 3
    Last Post: 4th November 2006, 18:46
  3. QTableWidget editing question
    By Trasmeister in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 18:46
  4. keypress while editing an item in QListWidget
    By Beluvius in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2006, 09:56
  5. Replies: 6
    Last Post: 5th March 2006, 21:05

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.