Results 1 to 3 of 3

Thread: QTableView and QStyledItemDelegate Persistent Editor Issue

  1. #1
    Join Date
    Aug 2019
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default QTableView and QStyledItemDelegate Persistent Editor Issue

    I have a QTableView and a QStyledItemDelegate derived class. I call tableView->setItemDelegateForColumn(0, new SpinBoxDelegate()) in the table constructor. When a row is added, I call tableView->openPersistentEditor(index). At this point I'd expect each cell to always show the SpinBox editor, but it only shows when the cell is clicked and enters into editing mode. Am I missing something?

  2. #2
    Join Date
    Aug 2019
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QTableView and QStyledItemDelegate Persistent Editor Issue

    I was able to get this working by doing something like:

    Qt Code:
    1. void SpinBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
    2. {
    3. _spinBox->setGeometry(option.rect);
    4. _spinBox->setValue(index.data().toInt());
    5. QPixmap map = QPixmap::grabWidget(_spinBox);
    6. painter->drawPixmap(option.rect.x(), option.rect.y(), map);
    7. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,120
    Thanks
    235
    Thanked 656 Times in 646 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: QTableView and QStyledItemDelegate Persistent Editor Issue

    @Linnda23: Use the "Thanks" button, please. It is a lot more effective than simply quoting a reply and adding a +1 and a broken image link.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Concept/Purpose/Use of Persistent Editor
    By ce_nort in forum Newbie
    Replies: 2
    Last Post: 17th December 2015, 20:31
  2. Handle ESC button in persistent editor in qlistwidget
    By sanket.mehta in forum Qt Programming
    Replies: 0
    Last Post: 15th November 2010, 07:30
  3. Persistent Editor Segmentation Fault
    By ArmanS in forum Qt Programming
    Replies: 0
    Last Post: 16th March 2009, 12:15
  4. QTreeWidget + Persistent Editor problem
    By Stephen Yee in forum Qt Programming
    Replies: 0
    Last Post: 6th May 2008, 17:25
  5. Help using the QTreeWidget persistent editor.
    By Billy Lee Black in forum Qt Programming
    Replies: 13
    Last Post: 18th July 2007, 19:59

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.