Qt_IM_51 - 8BitsCoding/RobotMentor GitHub Wiki


// main.cpp
#include <QtCore/QCoreApplication>

#include <qdebug.h>
#include <qmetaobject.h>
#include <qmetatype.h>
#include <qvariant.h>

#include "test.h"


void listClassInfo(QObject* obj) {
	qInfo() << obj->metaObject()->className();

	for (int i = 0; i < obj->metaObject()->classInfoCount(); i++) {
		QMetaClassInfo c = obj->metaObject()->classInfo(i);
		qInfo() << "Property: " << c.name() << " = " << c.value();
	}
}

int main(int argc, char *argv[])
{
	QCoreApplication a(argc, argv);

	test t;
	listClassInfo(&t);

	return a.exec();
}
// test.h
#pragma once

#include <QObject>

class test : public QObject
{
	Q_OBJECT

	Q_CLASSINFO("Author", "Byran Cairns")
	Q_CLASSINFO("Url", "http://www.voidrealms.com")

public:
	explicit test(QObject *parent = nullptr);
	~test();

signals:

public slots:
};

이미지

⚠️ **GitHub.com Fallback** ⚠️