property.cpp

来自「《精通QT4编程》共21章的源代码」· C++ 代码 · 共 36 行

CPP
36
字号
/////////////////////////////////////////////////////////////////// 静态属性。// #include <QtCore>// #include "weapon.h"// // int main(int argc, char *argv[])// {// 	QCoreApplication app(argc, argv);	// 	// 	CWeapon weapon;// 	weapon.setStatus(fired);// 	qDebug() << "status " << weapon.getStatus();// 	weapon.setProperty("xxx", 1);// 	qDebug() << "ID " << weapon.property("xxx").toInt();// 	//   	return 0;// }////////////////////////////////////////////////////////////////////// 动态属性。#include <QtCore>#include "weapon.h"int main(int argc, char *argv[]){	QCoreApplication app(argc, argv);			CWeapon weapon;	weapon.setStatus(fired);	qDebug() << "status " << weapon.getStatus();	weapon.setProperty("own", 1);	qDebug() << "own" << weapon.property("own").toInt();	  	return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?