QObject的多功能性使其相當大。輕量級QObject兼容基類
我想僅將它用於靜態屬性(本質上只是QMetaObject),而不會導致從QObject繼承的大量字節處罰。
是否有輕量級的等價物?
編輯
下面是分析結果 - 這是痛苦的具有30MB〜浪費了一箇中等規模的任務(有些可以〜20倍大)。注意b-written比率 - QObject構造函數設置了幾乎從未檢查過的狀態。
==10302== ======== ORDERED BY decreasing "max-bytes-live": top 10 allocators ========
==10302==
==10302== -------------------- 1 of 10 --------------------
==10302== max-live: 31,264,224 in 229,884 blocks
==10302== tot-alloc: 31,264,224 in 229,884 blocks (avg size 136.00)
==10302== deaths: none (none of these blocks were freed)
==10302== acc-ratios: 0.01 rd, 1.16 wr (459,768 b-read, 36,321,672 b-written)
==10302== at 0x4C275C0: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_exp-dhat-amd64-linux.so)
==10302== by 0x53E1551: QObject::QObject(QObject*) (in /usr/lib64/qt4/libQtCore.so.4.8.5)
==10302== by 0x50465CA: Util::Util() (util.h:84)
你根本不需要繼承QObject。你需要什麼功能? – 2014-08-27 15:35:58
'this-> metaObject() - > property(int)'和相關的。 – qdot 2014-08-27 15:59:34
元編譯僅適用於QObject派生類型。據我所知,沒有辦法沒有辦法。或者你將不得不實施自己的財產製度。 – jbh 2014-08-27 16:11:10