From 2c52f1d7e363b9828414ab15b7e1c18c5d7226c9 Mon Sep 17 00:00:00 2001 From: touwoyimuli Date: Fri, 13 Sep 2019 19:05:45 +0800 Subject: [PATCH] feat: Meat-Object System MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MeatObjectSystem(元对象系统)、Propert(属性和动态属性)和Q_CLASSINFO()(附加信息宏)的介绍和使用 --- QtMeatObjectEx/ExWidget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/QtMeatObjectEx/ExWidget.cpp b/QtMeatObjectEx/ExWidget.cpp index ff84e12..23b2747 100644 --- a/QtMeatObjectEx/ExWidget.cpp +++ b/QtMeatObjectEx/ExWidget.cpp @@ -45,8 +45,8 @@ void ExWidget::onAgeChange(int val) ExPerson* person = qobject_cast(sender()); //类型投射 QString name = person->property("name").toString(); QString sex = person->property("sex").toString(); - int age = person->getAge(); //通过接口函数,获得年龄 - //或使用 int age = person->property("age").toInt(); + int age = person->getAge(); //通过接口函数,获得年龄 + //或使用 int age = person->property("age").toInt(); ui->textEdit->appendPlainText(name+","+sex + QString::asprintf(",年龄=%d",age)); } @@ -54,7 +54,7 @@ void ExWidget::onSpinValChange(int val) { Q_UNUSED(val) - QSpinBox* spin = qobject_cast(sender()); //类型投射 + QSpinBox* spin = qobject_cast(sender()); //类型投射 if (spin->property("isBoy").toBool()) m_boy->setAge(ui->spinBoy->value()); else