[Qt-interest] 答复: how to know derive class
Konrad Rosenbaum
konrad at silmor.de
Thu Nov 11 12:00:48 CET 2010
On Thursday 11 November 2010 09:00:52 pengliang(彭亮) wrote:
> Thank you.
> But how to know which QWidget is QLineEdit and which is QComboBox?
> Is this only method?
Well, let's spell it out for you:
if(qobject_cast<QLineEdit*>(myobject)!=0)
qDebug("It's a Line Edit!");
else
if(qobject_cast<QComboBox*>(myobject)!=0)
qDebug("It's a Combo!");
else
qDebug("Ooops, it's something else!");
Now please read the docu of qobject_cast... ;-)
Konrad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101111/8846a0dc/attachment.bin
More information about the Qt-interest-old
mailing list