加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – qt未定义模板’QList’的隐式实例化

发布时间:2020-12-16 10:04:23 所属栏目:百科 来源:网络整理
导读:首先到达这个问题,我看了几个SO问题,其中一半似乎不适用,另一半,坦率地说,我只是不遵循. 问题: 这是我的问题的简单实现, ERROR : implicit instantiation of undefined template ‘QList VPNConnection ‘ 具体来说,struct User_VPN_Info中的VPNList对象带
首先到达这个问题,我看了几个SO问题,其中一半似乎不适用,另一半,坦率地说,我只是不遵循.

问题:

这是我的问题的简单实现,

ERROR : implicit instantiation of undefined template ‘QList<VPNConnection>

具体来说,struct User_VPN_Info中的VPNList对象带有上述错误的下划线.

值得注意的是,在一篇文章中提到让你的“孩子”在父母之上,否则就会实现一种原型,因此VPNConnection在User_VPN_Info之上.

基本说明:

结构User_VPN_Info应该以QList的形式实现struct VPNConnection以保存多个VPNConnection的

裸码:

struct VPNConnection{
    QString ip,cipher,protocol;
    int port;
    bool lzo_compression;

    VPNConnection(){}

    VPNConnection(QString _ip,QString _cipher,QString _protocol,int _port,bool _comp){
        ip = _ip;
        cipher = _cipher;
        protocol = _protocol;
        port = _port;
        lzo_compression = _comp;
    }
};

struct User_VPN_Info{
    QString vpn_name,vpn_expire;
    int DaysLeft;
    QList<VPNConnection> VPNList;
                         --------              <<< --- underlined with error   
    User_VPN_Info(){}

    User_VPN_Info(QString _vpn_name,QString _vpn_expire,int _DaysLeft){
        vpn_name = _vpn_name;
        vpn_expire = _vpn_expire;
        DaysLeft = _DaysLeft;
    }

    QString getString(){
        return(vpn_name + " + " + vpn_expire + " + " + QString::number(DaysLeft) + " ; ");
    }
};

我想了解导致此错误的原因以及为什么会出现此错误?

ERROR : implicit instantiation of undefined template ‘QList<VPNConnection>

UPDATE

经过一些研究,我来到了this

user – dasblinkenlight

apply as a pointer

因此改为:

QList<VPNConnection> *VPNList;

删除了这个问题.

有人愿意提供解释吗?

解决方法

那是因为你没有包含QList标题,所以你缺少QList的定义,如果你有一个这种类型的变量你需要它

QList<VPNConnection> VPNList;

但是,似乎您包含一些使QList标识符可用的标头(例如QString).否则,您将收到错误消息

unknown type name QList

这解释了为什么使用指针的解决方案工作正常,因为它只需要向前声明QList.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读