Results 1 to 10 of 10

Thread: QTableView add a remove button to each row

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2010
    Posts
    73
    Thanks
    6
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView add a remove button to each row

    Quote Originally Posted by StrikeByte View Post
    I was thinking of using a proxymodel to add the extra column and add a styleddelegate to it, dunno if this is possible

    just was checing into QProxyModel but it says its obsolete, it looks like i will need to write my own. oh just found that there is a QAbstractProxymodel I can use
    Smart thinking.....

    Can you use the QSortFilterProxyModel? It is not marked as deprecated / obsolete.

    http://qt-project.org/doc/qt-5/qsort...roxymodel.html

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

    Default Re: QTableView add a remove button to each row

    I've just tried it and it seems to work with a QAbstractProxymodel and a delegate.
    The proxymodel just adds an empty column and the delegate creates an pesistent editor in it (a modified QPushbutton)
    I started to suggest this yesterday, but didn't have the time to complete my reply. Glad you tried it and got it to work.

    Can you use the QSortFilterProxyModel? It is not marked as deprecated / obsolete.
    QSortFilterProxyModel is not appropriate for this use. It is used in cases where you want to 1) remove certain rows or columns from the source model and / or 2) display the source model sorted in a different order without changing the source model. There are several additional methods that must be implemented in QSortFilterProxyModel which have no relevance to the OP's problem. In his case, he wants to pass the source model unchanged, and simply add a new virtual column with a pushbutton in it. Depending on where he adds the virtual column, he won't have to do anything in QAbstractProxyModel's virtual methods except return QModelIndex instances that map directly to or from the same row and column of the source.

Similar Threads

  1. Remove row button in QTabelview
    By guidupas in forum Qt Programming
    Replies: 2
    Last Post: 10th March 2014, 14:31
  2. Remove max,min button on a QMainWindow
    By Krish_ng in forum Qt Programming
    Replies: 9
    Last Post: 3rd August 2012, 13:36
  3. Replies: 2
    Last Post: 26th April 2011, 11:44
  4. how to remove tab with closable button.
    By ishkabible in forum Newbie
    Replies: 8
    Last Post: 20th September 2010, 02:03
  5. Remove restore button
    By vermarajeev in forum Qt Programming
    Replies: 3
    Last Post: 26th June 2007, 13:29

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.