qobject_cast和shared_ptr

时间:2016-12-17 12:07:19

标签: c++ qt casting smart-pointers

抱歉我的英文。我有一些课。

class AdaptedWidget: public QWidget
{
    Q_OBJECT
public:
    AdaptedWidget(AdaptedWidget *parent = 0) {nothing}
    bool event(QEvent *event);
};

bool WindowManager::eventFilter(QObject *target, QEvent *event)
{
    auto window = qobject_cast<AdaptedWidget*>(target);
    **auto windowSharedPtr = std::make_shared<AdaptedWidget>(window);** //Error 
    ...

我需要从AdaptedWidget *智能指针创建。我需要覆盖复制构造函数?或者是执法类型中的问题?

0 个答案:

没有答案