文章目录 一、QPointer类型转换二、QPointer方法调用 一、QPointer类型转换 QVector存储T子类childT对象 T为抽象类,QVector无法存储,所以使用QPointer 调用子类方法时,需要转型 QVector<QPointer<T>> vector; for(auto it: vector){ QPoint<childT> ct = (childT*)(T*)it; ct.process(); } 二、QPointer方法调用 ct.pointerfun(); //调用pointer方法 ct->childTfun(); //调用childT方法