¿ìËÙÒµÎñͨµÀ

Qtѧϰ֮·(10):Meta-Objectϵͳ

×÷Õß ØýÃû¼¼Êõ À´Ô´ ³ÌÐòÉè¼Æ ä¯ÀÀ ·¢²¼Ê±¼ä 2012-06-29

Ç°Ãæ˵¹ý£¬QtʹÓõÄÊÇ×Ô¼ºµÄÔ¤±àÒëÆ÷£¬ËüÌṩÁ˶ÔC++µÄÒ»ÖÖÀ©Õ¹¡£ÀûÓÃQtµÄÐźŲۻúÖÆ£¬¾Í¿ÉÒ԰ѱ˴˶ÀÁ¢µÄÄ£¿éÏ໥Á¬½ÓÆðÀ´£¬²»ÐèҪʵÏÖÖªµÀÄ£¿éµÄÈκÎϸ½Ú¡£

ΪÁË´ïµ½Õâ¸öÄ¿µÄ£¬QtÌá³öÁËÒ»¸öMeta-Objectϵͳ¡£ËüÌṩÁËÁ½¸ö¹Ø¼üµÄ×÷ÓãºÐźŲۺÍÄÚÊ¡¡£

ÃæÏò¶ÔÏó³ÌÐòÉè¼ÆÀïÃæ»á½²µ½SmalltalkÓïÑÔÓÐÒ»¸öÔªÀàϵͳ¡£ËùνԪÀ࣬¾ÍÊÇÕâÀïËù˵µÄMeta-Class¡£Èç¹ûд¹ýHTML£¬»áÖªµÀ HTML±êÇ©ÀïÃæÒ²ÓÐÒ»¸ö<meta>£¬ÕâÊÇÓÃÓÚ˵Ã÷Ò³ÃæµÄijЩÊôÐԵġ£Í¬Ñù£¬QtµÄMeta-ObjectϵͳҲÊÇÀàËƵÄ×÷Óá£ÄÚÊ¡ÓÖ³ÆΪ·´É䣬ÔÊÐí³ÌÐòÔÚÔËÐÐʱ»ñµÃÀàµÄÏà¹ØÐÅÏ¢£¬Ò²¾ÍÊÇmeta-information¡£Ê²Ã´ÊÇmeta-informationÄØ£¿¾ÙÀýÀ´Ëµ£¬ÏñÕâ¸öÀà½ÐʲôÃû×Ö£¿ËüÓÐʲôÊôÐÔ£¿ÓÐʲô·½·¨£¿ËüµÄÐźÅÁÐ±í£¿ËüµÄ²ÛÁÐ±í£¿µÈµÈÕâЩÐÅÏ¢£¬¾ÍÊÇÕâ¸öÀàµÄmeta-information£¬Ò²¾ÍÊÇ“ÔªÐÅÏ¢”¡£Õâ¸ö»úÖÆ»¹ÌṩÁ˶Թú¼Ê»¯µÄÖ§³Ö£¬ÊÇQSA(Qt Script for Application)µÄ»ù´¡¡£

±ê×¼C++²¢Ã»ÓÐQtµÄmeta-informationËùÐèÒªµÄ¶¯Ì¬meta-information¡£ËùÒÔ£¬QtÌṩÁËÒ»¸ö¶ÀÁ¢µÄ¹¤¾ß£¬moc£¬Í¨¹ý¶¨ÒåQ_OBJECTºêʵÏÖµ½±ê×¼C++º¯ÊýµÄת±ä¡£mocʹÓô¿C++ʵÏֵģ¬Òò´Ë¿ÉÒÔÔÙÈκαàÒëÆ÷ÖÐʹÓá£

ÕâÖÖ»úÖƹ¤×÷¹ý³ÌÊÇ£º

Ê×ÏÈ£¬Q_OBJECTºêÉùÃ÷ÁËһЩQObject×ÓÀà±ØÐëʵÏÖµÄÄÚÊ¡µÄº¯Êý£¬ÈçmetaObject()£¬tr(),qt_metacall()µÈ£»

µÚ¶þ£¬QtµÄmoc¹¤¾ßʵÏÖQ_OBJECTºêÉùÃ÷µÄº¯ÊýºÍËùÓÐÐźţ»

µÚÈý£¬QObject³ÉÔ±º¯Êýconnect()ºÍdisconnect()ʹÓÃÕâЩÄÚÊ¡º¯ÊýʵÏÖÐźŲ۵ÄÁ¬½Ó¡£

ÒÔÉÏÕâЩ¹ý³ÌÊÇqmake£¬mocºÍQObject×Ô¶¯´¦ÀíµÄ£¬Äã²»ÐèҪȥ¿¼ÂÇËüÃÇ¡£Èç¹ûʵÏÖºÃÆæµÄ»°£¬¿ÉÒÔͨ¹ý²é¿´QMetaObjectµÄÎĵµºÍmocµÄÔ´´úÂëÀ´Ò»¶Ã·¼ÈÝ¡£

³ö´¦: http://devbean.blog.51cto.com/448512/199472

ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!

·ÖÏíµ½£º ¸ü¶à

Copyright ©1999-2011 ÏÃÃÅÁèÖڿƼ¼ÓÐÏÞ¹«Ë¾ ÏÃÃÅÓÅͨ»¥Áª¿Æ¼¼¿ª·¢ÓÐÏÞ¹«Ë¾ All rights reserved

µØÖ·(ADD)£ºÏÃÃÅÈí¼þÔ°¶þÆÚÍûº£Â·63ºÅ701E£¨¶«ÄÏÈÚͨÅÔ£© Óʱà(ZIP)£º361008

µç»°£º0592-5908028 ´«Õ棺0592-5908039 ×ÉѯÐÅÏ䣺web@lingzhong.cn ×ÉѯOICQ£º173723134

¡¶ÖлªÈËÃñ¹²ºÍ¹úÔöÖµµçÐÅÒµÎñ¾­ÓªÐí¿ÉÖ¤¡·ÃöB2-20100024  ICP±¸°¸:ÃöICP±¸05037997ºÅ