C++ (Qt)
struct TekValOUT_SBU
{
float tec_value_sbu_1;
float tec_value_sbu_2;
float tec_value_sbu_3;
float tec_value_sbu_4;
float tec_value_sbu_5;
float tec_value_sbu_6;
char tec_value_sbu_7[8];
};
class ListModelBrowser: public QAbstractItemModel
{
Q_OBJECT
public:
explicit ListModelBrowser(QObject*parent = 0);
virtual ~ListModelBrowser();
QString stroka(char *);
public:
int columnCount(const QModelIndex &parent) const;
int rowCount(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role) const;
QModelIndex index(int row, int column, const QModelIndex &parent) const;
QModelIndex parent(const QModelIndex &child) const;
// bool setData(const QModelIndex &index, const QVariant &value, int role);
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
//!!! void initRoot(QObject*);
public Q_SLOTS:
void setRoot(QModelIndex);
void initRoot(QObject*);
public:
QObject*root;
};
QVariant ListModelBrowser::data(const QModelIndex &index, int role) const
{
if (index.column() == 3 && (QVariant(element->metaObject()->className())).toString() == "Preference" )
{
Preference *pref = dynamic_cast<Preference*>(element);
Function *function = (Function*)(pref->pointFunction);
if(function->typeFunction == Monitoring)
{
if(index.column() == 3)
{
Device *device = (Device*)(function->parent());
switch(index.row())
{
case 0: return device->tvOBuf.tec_value_sbu_1;
case 1: return device->tvOBuf.tec_value_sbu_2;
case 2: return device->tvOBuf.tec_value_sbu_3;
case 3: return device->tvOBuf.tec_value_sbu_4;
case 4: return device->tvOBuf.tec_value_sbu_5;
case 5: return device->tvOBuf.tec_value_sbu_6;
case 6: return stroka((device->tvOBuf).tec_value_sbu_7); //!!!!!!!!!Ошибка????????????
default:
break;
}
}
}
return QVariant();
}
QString ListModelBrowser::stroka(char *data)
{
QString outStr;
char strBufHex[8];
for(int i = 0; i<8; i++)
{
::sprintf(strBufHex,"%d",(unsigned char)(data[i]));
outStr.append(strBufHex);
}
return outStr;
}
При компиляции выдается ошибка
error: passing 'const ListModelBrowser' as 'this' argument of 'QString ListModelBrowser::stroka(char*)' discards qualifiers