May 5, 2011

quadbyte quadbyte
Lab Rat
6 posts

QStyledItemDelegate on a QTableView problem

 

Hi all,

I have a curious problem when using QStyledItemDelegate class on a QTableView. In fact I started from wiki snippets ‘Combo Boxes in Item Views’, except than my Qtable is not a QTableWidget but a QTableView populated by a QAbstractTableModel.

All is working fine except when I try enter edit mode (by dbclick for ex) the function createEditor() of the delegate class is never called although editTriggers are set to AllEditTriggers.

I must forget something to make the tableView editable, but what ?

6 replies

May 5, 2011

ZapB ZapB
Ant Farmer
1427 posts

Have you implemented a correct flags() function for your model? Same for setData()? Have you tried your model with the qmodeltest program to check for other common mistakes?

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

May 6, 2011

Gerolf Gerolf
Robot Herder
3286 posts

Hi quadbyte,

did you try whether your model is editable, without your custom delegate?
That could deliver a first idea, where to search for the bug.

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

May 6, 2011

quadbyte quadbyte
Lab Rat
6 posts

@ZapB, I check yours points.
@Gerolf,
You are correct Gerolf, I was not clear in my initial mail, but my Model seems to be not editable (even without custom Delegate).

I read the Qt doc to see how to make a Model editable…

Thanks a lot Guys for you help

May 6, 2011

Gerolf Gerolf
Robot Herder
3286 posts

Let me give you a hint:

an editable model [doc.qt.nokia.com]

The points are the method flags and setData.

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

May 6, 2011

ZapB ZapB
Ant Farmer
1427 posts
Gerolf wrote:
The points are the method flags and setData.

Just like I mentioned ;-)

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

May 7, 2011

quadbyte quadbyte
Lab Rat
6 posts

It’s working, thanks a lot

 
  ‹‹ problem with readyread() and QFile      [Moved] does QTableWidget::clear() also delete QTableWidgetItems ? ››

You must log in to post a reply. Not a member yet? Register here!