另一个宏中的Q_PROPERTY宏 [英] Q_PROPERTY macro within another macro
问题描述
如何将 Q_PROPERTY
宏放在另一个辅助宏中?
How to put the Q_PROPERTY
macro inside another, helper-macro?
#define SimpleAllinOne(member, _type) \
public: \
void Set##member(_type _arg_##member) \
{ \
m_##member = _arg_##member;\
} \
_type Get##member() const\
{ \
return m_##member;\
} \
private: \
_type m_##member; \
Q_PROPERTY(_type member READ Get##member WRITE Set##member)
..不起作用.预处理程序输出( gcc -E标志
或 nmake/jom/P标志
)显示了(有效的)setter/getter方法和相应的成员变量,但没有显示 Q_PROPERTY
行.
.. does not work. Preprocessor output (gcc -E flag
or nmake/jom /P flag
) shows the (working) setter/getter methods and corresponding member variable but not a single character for the Q_PROPERTY
line.
更新:似乎可以与Qt5.1一起使用,后者可以正确扩展用户宏.Qt4.8不起作用,Qt5.0尚未经过测试.请参见#QTBUG-35 (感谢??)./p>Qt4.x中的
Update: It seems to work with Qt5.1 which expands the user macros properly. Qt4.8 does not work, Qt5.0 has not been tested. See #QTBUG-35 (thanks to ??).
推荐答案
moc无法识别预处理器宏中的Q_宏.
moc in Qt4.x does not recognize Q_ macros within preprocessor macros.
moc会在解析Q_宏之前扩展预处理器宏.
moc in Qt5.x expands the preprocessor macros before parsing the Q_ macros.
这篇关于另一个宏中的Q_PROPERTY宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!