Создал свой класс:
channel.h
C++ (Qt)
class Channel
{
public:
Channel(){}
Channel(const Channel &other){}
~Channel(){}
Channel(QString provider, QString title, QString thumbnail, QString category, int id, int catId);
//getters
QString getProvider() const {return m_provider;}
QString getTitle() const {return m_title;}
QString getThumb() const {return m_thumbnail;}
QString getCategory() const {return m_category;}
int getId() const {return m_id;}
int getCategoryId() const {return m_categoryId;}
private:
QString m_provider;
QString m_title;
QString m_category;
QString m_thumbnail;
int m_id;
int m_categoryId;
};
Q_DECLARE_METATYPE(Channel);
Q_DECLARE_METATYPE(QList<Channel>);
channel.cpp
C++ (Qt)
#include "channel.h"
#include <QDebug>
Channel::Channel(QString provider, QString title, QString thumbnail, QString category, int id, int catId)
{
m_provider = provider;
m_title = title;
m_thumbnail = thumbnail;
m_category = category;
m_id = id;
m_categoryId = catId;
}
почему при попытке засунуть его в QList<Channel> в списке данные превращаются в мусор?
Засовываю вот так:
C++ (Qt)
QList<Channel> channels;
for(int i=0; i<ls.size(); i++)
{
Channel c("ThickTV",ls.at(i).toMap()["name"].toString(),"...","Все",i,0); // ls.at(i).toMap()["name"].toString() - данное преобразование возвращает вполне нормальное название канала, проверял
channels.append(c);
}
qWarning()<< "size " << channels.size();
for(int i=0; i<channels.size(); i++)
{
qWarning() << channels[i].getProvider() << channels[i].getTitle() << channels[i].getThumb() <<
channels[i].getCategory() << channels[i].getCategoryId() << channels[i].getId();
}
Получаю вывод:
[09:42:22] Warning: size 156
[09:42:22] Warning: "" "" "" "" 147339080 147466176
[09:42:22] Warning: "" "" "" "" 147466080 147466208
[09:42:22] Warning: "" "" "" "" 147339080 147466176
[09:42:22] Warning: "" "" "" "" 147466080 147466208
[09:42:22] Warning: "" "" "" "" 147339080 147466176
[09:42:22] Warning: "" "" "" "" 147339080 147466208
[09:42:22] Warning: "" "" "" "" 147466256 147466176
[09:42:22] Warning: "" "" "" "" 147466256 147466208
[09:42:22] Warning: "" "" "" "" 147466256 147466176
[09:42:22] Warning: "" "" "" "" 147466256 147466208
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147466208
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147466208
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147466208
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147466208
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147466208
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147466208
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147466208
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147466208
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147466208
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147466208
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466720 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147467472
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147467472
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147467472
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147467472
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147467472
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147467472
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147467472
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147467472
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147467472
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147467472
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147467472
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147467472
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147467472
[09:42:22] Warning: "" "" "" "" 147466464 147466176
[09:42:22] Warning: "" "" "" "" 147466464 147467472
[09:42:22] Warning: "" "" "" "" 147466464 147466208
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147339056
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147339056
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147339056
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147339056
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147339056
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147467464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 147466464 147466160
[09:42:22] Warning: "" "" "" "" 147466464 147468888
[09:42:22] Warning: "" "" "" "" 7143521 7208960
[09:42:22] Warning: "" "" "" "" 147466464 147465832
[09:42:22] Warning: "" "" "" "" 147466464 147468440
[09:42:22] Warning: "" "" "" "" 147466464 147468408
[09:42:22] Warning: "" "" "" "" 147466464 147468440
[09:42:22] Warning: "" "" "" "" 147466464 147468408
[09:42:22] Warning: "" "" "" "" 147466464 147468440
[09:42:22] Warning: "" "" "" "" 147466464 147468408
[09:42:22] Warning: "" "" "" "" 147466464 147468440
[09:42:22] Warning: "" "" "" "" 147466464 147468408
[09:42:22] Warning: "" "" "" "" 147466464 147468440
[09:42:22] Warning: "" "" "" "" 147466464 147468408
[09:42:22] Warning: "" "" "" "" 147466464 147468440
[09:42:22] Warning: "" "" "" "" 147466464 147468408
[09:42:22] Warning: "" "" "" "" 147466464 147468440
[09:42:22] Warning: "" "" "" "" 147466464 147468408
[09:42:22] Warning: "" "" "" "" 147466464 147468440
[09:42:22] Warning: "" "" "" "" 147466464 147468408
[09:42:22] Warning: "" "" "" "" 147466464 147468440
[09:42:22] Warning: "" "" "" "" 147466464 147468408
[09:42:22] Warning: "" "" "" "" 147466464 147468440
[09:42:22] Warning: "" "" "" "" 147466464 147468408
[09:42:22] Warning: "" "" "" "" 147466464 147468440
[09:42:22] Warning: "" "" "" "" 147466464 147468408
[09:42:22] Warning: "" "" "" "" 147466464 147468440
[09:42:22] Warning: "" "" "" "" 147466464 147468408
[09:42:22] Warning: "" "" "" "" 147466464 147468440
[09:42:22] Warning: "" "" "" "" 147466464 147468408
[09:42:22] Warning: "" "" "" "" 147466464 147468440
[09:42:22] Warning: "" "" "" "" 147466464 147468408
[09:42:22] Warning: "" "" "" "" 147466464 147468440
[09:42:22] Warning: "" "" "" "" 147466464 147468408
[09:42:22] Warning: "" "" "" "" 147466464 147468440