Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

qt implicit instantiation of undefined template 'QList<VPNConnection>'

Tags:

c++

class

struct

qt

First arriving at this issue, I looked at a few SO questions, of which half do not seem to apply and the other half, quite frankly, I just do not follow.

Problem:

This is a simple implementation of my issue,

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

Specifically, the VPNList object in struct User_VPN_Info is underlined with the above error.

Something of note, it was mentioned in one post to have your "children" above the parent, else one would implement a type of prototype, thus the VPNConnection being ontop of the User_VPN_Info.

Basic Explaination:

The struct User_VPN_Info should implement the struct VPNConnection in the form of a QList to hold multiple VPNConnection's

Bare Code:

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) + " ; ");
    }
};

I would like to understand what causes this error and why it occurs here?

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

UPDATE

After some more research, I came accross this

user - dasblinkenlight

apply as a pointer

Thus changing to:

QList<VPNConnection> *VPNList;

removed this issue.

Anyone care to offer an explaination?

like image 227
CybeX Avatar asked Oct 25 '16 23:10

CybeX


1 Answers

That's because you didn't include QList header, so you are missing the definition of QList, which you need if you have a variable of that type at

QList<VPNConnection> VPNList;

However, it seems that you include some header (e.g. QString) that makes QList identifier available. Otherwise, you will get an error

unknown type name QList

This explains why the solution of using a pointer works fine, since it merely needs QList to be forward declared.

like image 185
HazemGomaa Avatar answered Nov 15 '22 12:11

HazemGomaa