[Qt-interest] QMetaObject and its method() function
Louis Du Verdier
zemassacreur at yahoo.fr
Sat Jan 16 02:29:49 CET 2010
Hello,
First, please excuse me if my english is bad, I am french.
I am writing an article about the Qt meta-objects system (in french), so I am creating an application which goal would be to illustrate that I say in it.
This application have to show all methods availible by the class. There it is the first code version :
QTableWidget *widget = new QTableWidget(this);
widget->setColumnCount(3);
widget->setHorizontalHeaderItem(0, new QTableWidgetItem("Type d'acces"));
widget->setHorizontalHeaderItem(1, new QTableWidgetItem("Type de methode"));
widget->setHorizontalHeaderItem(2, new QTableWidgetItem("Type de fonction"));
widget->setRowCount(_metaObject->methodCount());
for(int i = 0; i < _metaObject->methodCount(); i++)
{
widget->setVerticalHeaderItem(i, new QTableWidgetItem(_metaObject->method(i).signature()));
if(_metaObject->method(i).access() == QMetaMethod::Private) widget->setItem(i, 0, new QTableWidgetItem("Prive"));
if(_metaObject->method(i).access() == QMetaMethod::Protected) widget->setItem(i, 0, new QTableWidgetItem("Protege"));
if(_metaObject->method(i).access() == QMetaMethod::Public) widget->setItem(i, 0, new QTableWidgetItem("Public"));
if(_metaObject->method(i).methodType() == QMetaMethod::Signal) widget->setItem(i, 1, new QTableWidgetItem("Signal"));
else if(_metaObject->method(i).methodType() == QMetaMethod::Slot) widget->setItem(i, 1, new QTableWidgetItem("Slot"));
else widget->setItem(i, 1, new QTableWidgetItem("Autre"));
widget->setItem(i, 2, new QTableWidgetItem(_metaObject->method(i).typeName()));
}
The only problem is that the "else" condition, about the method type, is never called, and only the signals and slots are shown on the tableWidget.
If I create a private function (not a slot), this one is not shown on the window. I think it is because the meta-object system don't store this kind of function, but if someone can tell me if I am in the truth...
But if it is not wrong, this means that the enums QMetaMethod::Method and QMetaMethod::Constructor do not have any utility ?
Thank you in advance,
Louis.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100116/d4609e96/attachment.html
More information about the Qt-interest-old
mailing list