init study Qt

This commit is contained in:
cs180
2025-08-24 11:10:27 +08:00
commit c3e374c375
9 changed files with 417 additions and 0 deletions

33
qperson.h Normal file
View File

@@ -0,0 +1,33 @@
#ifndef QPERSION_H
#define QPERSION_H
#include <QObject>
class QPerson : public QObject
{
Q_OBJECT
Q_CLASSINFO("author", "Ding")
Q_CLASSINFO("company", "UPC")
Q_CLASSINFO("version", "1.0.0")
Q_PROPERTY(int age READ age WRITE setAge NOTIFY ageChanged)
Q_PROPERTY(QString name MEMBER m_name)
Q_PROPERTY(int score MEMBER m_score)
private:
int m_age=10;
QString m_name;
int m_score=60;
public:
explicit QPerson(QString fName, QObject *parent = nullptr);
int age();
void setAge(int val);
void incAge();
signals:
void ageChanged(int val);
public slots:
};
#endif // QPERSON_H