Results 1 to 4 of 4

Thread: QListWidget in QtableView with scrollbar

  1. #1
    Join Date
    Dec 2014
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default QListWidget in QtableView with scrollbar

    To make a long story short, I need an answer to this previous asked question -> http://www.qtcentre.org/threads/4510...-How-To-Scroll

    I'm getting the widget to appear in the qtableview, but I can't use the vertical scrollbar.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListWidget in QtableView with scrollbar

    Are you embedding actual QListWidget instances in the cells of the table, or are you doing as the author of that post did and creating a delegate that simply paints the appearance of a QListWidget into the cell?

  3. #3
    Join Date
    Dec 2014
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QListWidget in QtableView with scrollbar

    The latter. Is that the wrong way to go about it? I basically just want to have the listwidget in the cell so the user can scroll through it.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListWidget in QtableView with scrollbar

    The latter. Is that the wrong way to go about it?
    Yes. All you are getting is a picture of the widget which is being painted into the cell as an image. It's not a widget, you can't interact with it.

    There are two things you can do:

    1 - Create actual list widgets and set them as the index widgets for the cells you want. QTableView::setIndexWidget() If the table is of any significant size, you will take a huge preformance hit. The widgets are disconnected from the model, so you have to manually update the widgets when the model changes, and if the model needs to change based on selections from the list, you'll need to do that yourself as well.

    2 - Create an item delegate based on a list widget and install that on the cells where needed. Item delegates are intended to be used when editing a cell's content, and are normally not visible when the cell does not have focus.

    Neither choice is optimal for what you are trying to do.

Similar Threads

  1. QListWidget scrollbar position
    By papillon in forum Qt Programming
    Replies: 1
    Last Post: 9th September 2011, 00:44
  2. QListWidget Scrollbar
    By WeeMan in forum Qt Programming
    Replies: 6
    Last Post: 19th March 2010, 00:15
  3. QListWidget + setWindowFlags = bad scrollbar
    By trallallero in forum Qt Programming
    Replies: 5
    Last Post: 9th December 2009, 12:06
  4. QTableView and its Scrollbar question
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 28th May 2008, 15:23
  5. QTableView : ScrollBar ?
    By titoo in forum Qt Programming
    Replies: 7
    Last Post: 15th February 2007, 09:52

Tags for this Thread

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.