Results 1 to 6 of 6

Thread: QListWidget Delegate in QTableView Column How To Scroll

  1. #1
    Join Date
    Oct 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QListWidget Delegate in QTableView Column How To Scroll

    I have created a delegate class for the QListWidget and I have added the delegate to a column of a QTableView. My scrollbars appear in my QListWidget when needed but the scroll does not appear to work. I am somewhat new to using the QTableView and delegates. Is there something, perhaps in the editorevent method that must be implemented to allow scrolling to work? If anyone has an example or can point me to something I would appreciate it.

    Thanks in advance!

  2. #2
    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: QListWidget Delegate in QTableView Column How To Scroll

    What scrollbars do you mean? The one from QTableView? What does a delegate have to do with that?
    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.


  3. #3
    Join Date
    Oct 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget Delegate in QTableView Column How To Scroll

    I have created a delegate class "CheckedListBoxDelegate : public QStyledItemDelegate" and I am creating a QListWidget in the paint method to be drawn for a column in my QTableView. The scrollbars that I am talking about are the scrollbars on the QListWidget. The up/down arrows on the QListWidget's scrollbars are being drawn but do not allow the widget to scroll.

    Qt Code:
    1. void CheckedListBoxDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
    2. {
    3. QStringList list = index.data().toStringList();
    4. QListWidget list_widget;
    5.  
    6. list_widget.resize(option.rect.width(),option.rect.height());
    7.  
    8. foreach(QString str, listBoxData)
    9. {
    10. QListWidgetItem *item = new QListWidgetItem(str);
    11. item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | Qt::ItemIsEnabled);
    12.  
    13. if(list.contains(str))
    14. {
    15. item->setCheckState(Qt::CheckState::Checked);
    16. }
    17. else
    18. {
    19. item->setCheckState(Qt::CheckState::Unchecked);
    20. }
    21.  
    22. list_widget.addItem(item);
    23. }
    24.  
    25. painter->save();
    26.  
    27. painter->setClipRect(option.rect);
    28.  
    29. painter->translate(option.rect.topLeft());
    30. list_widget.render(painter);
    31. painter->restore();
    32. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    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: QListWidget Delegate in QTableView Column How To Scroll

    Quote Originally Posted by kbatch View Post
    I have created a delegate class "CheckedListBoxDelegate : public QStyledItemDelegate" and I am creating a QListWidget in the paint method to be drawn for a column in my QTableView. The scrollbars that I am talking about are the scrollbars on the QListWidget. The up/down arrows on the QListWidget's scrollbars are being drawn but do not allow the widget to scroll.
    You are just rendering the looks of a widget so it seems obvious any interaction with it will fail since the widget is not really there.
    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.


  5. #5
    Join Date
    Oct 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget Delegate in QTableView Column How To Scroll

    Yes, that has occurred to me. Any suggestions as to how someone may go about doing what I am attempting to do?

  6. #6
    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: QListWidget Delegate in QTableView Column How To Scroll

    First I would ask for a purpose of doing what you are doing. Whatever it is, I don't think embedding a list widget inside a table view is a good solution. I would probably rather use QTreeView or a different solution.
    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.


Similar Threads

  1. Customising the scroll bar in a QListWidget
    By balasaravanan in forum Qt Programming
    Replies: 1
    Last Post: 4th March 2011, 07:57
  2. Problems with scroll in QListWidget
    By VilmarCeller in forum Qt Programming
    Replies: 1
    Last Post: 16th December 2010, 10:54
  3. Replies: 1
    Last Post: 29th April 2010, 05:21
  4. Replies: 0
    Last Post: 28th December 2009, 12:24
  5. QTreeWidget scroll only one column
    By nina1983 in forum Qt Programming
    Replies: 3
    Last Post: 13th August 2008, 15:07

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.