Mach to Qt standard
-
Hi,
How change my error list creted in standard C++ to Qt posibility:
class MyError { int ErrorCode; public: std::map<int, std::string> ErrorList; MyError(int ErrCode) { ErrorCode = ErrCode; ErrorList[0x00] = "Unknown error."; } std::string getMessage() { return this->ErrorList[this->ErrorCode]; } };
?
Regards
-
@Damian7546 said in Mach to Qt standard:
How change my error list creted in standard C++ to Qt posibility:
What does this mean and why do you need to change it?
-
@Damian7546 You can do that (but you can also use std container in Qt applications). What is the problem?
-
@jsulm Ok,
So if I stay in oryginal library, please tell me how can I normalize :
typedef std::vector<unsigned char> vec_bytes;
to usingQByteArray
?Examle:
void MyFunction::showresponse(const QByteArray &result) { if(this->CheckErrors(result__)) { //do something } }
How convert
QByteArray resutl;
tovec_bytes result__;
? -
@Damian7546 In you case it seems to be way easier to use QByteArrray instead of std::vector<unsigned char> (change vec_bytes result__ to QByteArray).
If you want to have such a mix then you will need to iterate over the QByteArray elements and add them to std::vector<unsigned char>. -
@Damian7546
Why mix Qt andstd::
stuff? You want to append tobuffer
, so why not searchQByteArray
doc page forappend
(orinsert
), e.g. QByteArray &QByteArray::append(const QByteArray &ba) ? -
-
We don't know since we don't know what
this->GetCRC16(buffer, buffer.size())
does or returns. -
If I had to guess, I would say this is not right. If you are passing
buffer, buffer.size()
toGetCRC16()
what does that do inbuffer
and why would you want to append the result to CRC if you have already called something which perhaps/at a guess already appends there? [Actually, it may be correct, providedGetCRC16()
readsbuffer.size()
bytes frombuffer
and returns a newQByteArray
, does not write intobuffer
.]
-