Results 1 to 2 of 2

Thread: paint clears the data in qtableview

  1. #1
    Join Date
    May 2016
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default paint clears the data in qtableview

    I have to display data in a QTableView, I have a model which has data but I subclassed QAbstractProxyModel to Transpose the data in my model, Further I need only one button in the QTableView which can be achieved by subclassing QItemDelegate, Now the problem is when I set view->setItemDelegate(MyItemDelegate)(for the pushbutton); view->setModel(myModel); view->show(); ... I find only the pushbutton which I painted in the paint method when delegating the QItemDelegate. I searched and found that I need to setModelData() and setEditorData() to set the values from myModel.. But I dont know if it is correct and if it is How do I setdata().... Thanks in advance

    PS:- when i try view->setModel(MyModel); view->show(); without setItemDelegate... I could see the data in the QTableView... But I dont see the data after delegating ... All this pain just for a QPushButton in a QTableView

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: paint clears the data in qtableview

    The setModelData() and setEditorData() methods allow the delegate to transfer data from an editor widget to/from the model.
    So these become necessary when the delegate creates editor widgets, i.e. when it implements createEditor().

    The view calls setModelData() when it needs to transfer data from an editor widget into the model.
    It calls setEditorData() when it needs to transfer data from the model into an editor widget.

    The delegate, which has created the editor can either use the given model index to interacte with the model, or get the model from the index and call methods on that directly.

    Cheers,
    _

Similar Threads

  1. Replies: 2
    Last Post: 28th April 2016, 07:44
  2. QTableView line edit clears the text on edit
    By PlasticJesus in forum Qt Programming
    Replies: 5
    Last Post: 14th March 2015, 19:06
  3. Paint in a QtableView
    By StrikeByte in forum Qt Programming
    Replies: 3
    Last Post: 19th December 2014, 16:37
  4. QTableView paint row in stylesheet hover
    By estanisgeyer in forum Qt Programming
    Replies: 3
    Last Post: 23rd October 2012, 09:17
  5. Paint streaming pixel data
    By jmsbc in forum Qt Programming
    Replies: 4
    Last Post: 23rd September 2008, 04:15

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.