[Qt-interest] ModelView - QItemEditorFactory not returning correct editor for boolean data?
Daniel Price
daniel.price at fxhome.com
Wed Nov 25 13:54:49 CET 2009
It is QVariant().toBool().
Even if I return a bool directly I still get a line edit.
-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Jan
Sent: 25 November 2009 12:38
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] ModelView - QItemEditorFactory not returning correct editor for boolean data?
Does your view "know" that you are returning a boolean?
Is it a QVariant(...).toBool() or QVariant(QString("true")) or
QVariant(true) in data()?
Jan
Daniel Price schrieb:
> My model contains Booleans (bool) displayed by a TreeView. According to the documentation, the view has a default QItemEditorFactory that recognizes basic types like string and bool and provides appropriate editors. The docs say I should get QComboBoxes for Boolean values. But I don't - I get plain text fields with the text 'true' or 'false' where typing a non-negative number is interpreted as 'true'.
>
> All I want to do is add a popup menu or checkbox for editing Boolean values. I can create my own custom delegate but this seems like overkill and the docs imply that this is now unnecessary. What am I missing?
>
> QItemEditorFactory was apparently added in 4.3 but all the books I have cover only 4.0 so they do it the hard way.
>
>
>
> Daniel Price
> Software Engineer
> FXhome Limited
>
>
> ________________________________
> This email is confidential. It may also be privileged or otherwise protected by work product immunity or other legal rules. If you are not the intended recipient please notify the sender. Please delete the message from all places in your computer where it is stored. You should not copy the email or use it for any purpose or disclose its contents to any other person.To do so may be unlawful. Email is an informal means of communicating and may be subject to data corruption accidentally or deliberately. For this reason it is inappropriate to rely on advice contained in an email without obtaining written confirmation of it first.
>
> FXhome Limited is a limited company registered in England and Wales. Registered number: 04172812. Registered office: The Henderson Business Centre, Ivy Road, Norwich, Norfolk, NR5 8BF, U.K.
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list