[Qt-interest] how I can know the widget is editable?

Shabd Swarup V shabd at cadence.com
Fri Mar 20 16:24:31 CET 2009


Using metaObject className() would return the actual implemented class
name and not the Qt base class name. I think this will not be suitable
in your case.

Even if you use a QMap to store the list of "potentially editable"
widgets, you would need to type cast to that type of widget to be able
to call the appropriate method to find out if it is editable, eg.
isReadOnly() in case of QLineEdit, QTextEdit.

Hope this helps.

Thanks,
Shabd

-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of
Oliver.Knoll at comit.ch
Sent: Friday, March 20, 2009 8:39 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] how I can know the widget is editable?

Shabd Swarup V wrote on Friday, March 20, 2009 9:53 AM:

> You would probably need to type cast (using qobject_cast) to each
> widget kind which CAN be editable and check. 

Or you could use http://doc.trolltech.com/4.5/qmetaobject.html#className
which returns the class name as const char *, and then do a quick lookup
in a list (better yet: a QMap or something :) of "well known editable
widgets". Might be slightly more performant than qobject_casting to all
possible widgets.

Cheers, Oliver
-- 
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
_______________________________________________
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