逛奔的蜗牛

我不聪明,但我会很努力

   ::  :: 新随笔 ::  ::  :: 管理 ::
@import url(http://www.cppblog.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
Adding a Q_DECLARE_METATYPE() makes the type known to all template based functions, including QVariant.
Note that if you intend to use the type in queued signal and slot connections or in QObject's property system,
you also have to call qRegisterMetaType() since the names are resolved at runtime.

class BH {
public:
    BH() {
        value = 10;
    }

    int value;
};

Q_DECLARE_METATYPE(BH)

BH bh;
QVariant var = QVariant::fromValue(bh);

qDebug() << var.canConvert<BH>();

BH bh2 = var.value<BH>();
qDebug() << bh2.value;

posted on 2013-09-02 15:16 逛奔的蜗牛 阅读(3237) 评论(0)  编辑 收藏 引用 所属分类: Qt

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理