[Qt-interest] boolean field checkbox QTableView

Andreas Pakulat apaku at gmx.de
Wed Feb 11 17:40:54 CET 2009


On 11.02.09 15:19:18, Linos wrote:
> Andreas Pakulat escribió:
> > Then data() still returns something meaningful for the DisplayRole which
> > you should be able to disable as well. That should also get rid of the
> > combobox.
> 
> I have changed the data method to return a null QVariant in DisplayRole and i 
> know don't see the text in the column in display but without delegate i still 
> see the combobox to edit it with "True, False" values, i think this is the 
> default behavior to EditRole in boolean columns, i think the only solution here 
> it is the persistent editor that Christopher has pointed me.

Attached is a small sample that works as you describe I believe, it allows
to check/uncheck the checkbox in the checkbox column by clicking on it and
it allows to edit the string just as normal by double clicking.

As you can see one also needs to handle the CheckStateRole in setData, in
this example I'm explicitly handling Qt::Checked/Qt::Unchecked, but it may
also work with plain boolean.

Andreas

-- 
You will obey or molten silver will be poured into your ears.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: checkablemodel.zip
Type: application/zip
Size: 2002 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090211/5f300710/attachment.zip 


More information about the Qt-interest-old mailing list