CString 在 Qt 应用程序中的使用
我想使用我的 Qt 应用程序中的这段代码:
#ifndef AS_I2C__HPP__
#define AS_I2C__HPP__
#include <cstring>
#include "as_i2c.h"
class AsI2c
{
public:
AsI2c(int aBusNumber);
virtual ~AsI2c();
long setSlaveAddr(unsigned char aAddr);
long getSlaveAddr() const;
long read(unsigned char *aData, size_t aSize) const;
long write(unsigned char *aData, size_t aSize);
long readReg(unsigned char aReg, unsigned char *aData, size_t aSize) const;
long writeReg(unsigned char aReg, unsigned char *aData, size_t aSize);
long readMsg(unsigned char *aWData, unsigned char aWriteSize, unsigned char *aRData, size_t aReadSize);
long readRegByte(unsigned char aReg) const;
long writeRegByte(unsigned char aReg, unsigned char aVal);
protected:
mutable struct as_i2c_device *mDev;
};
#endif // AS_I2C__HPP__
我使用 qt-everywhere 4.7 来交叉编译它,我该怎么做? (该代码是低级 C 函数的 C++ 包装器)。
问候。
I want to use this code from my Qt application :
#ifndef AS_I2C__HPP__
#define AS_I2C__HPP__
#include <cstring>
#include "as_i2c.h"
class AsI2c
{
public:
AsI2c(int aBusNumber);
virtual ~AsI2c();
long setSlaveAddr(unsigned char aAddr);
long getSlaveAddr() const;
long read(unsigned char *aData, size_t aSize) const;
long write(unsigned char *aData, size_t aSize);
long readReg(unsigned char aReg, unsigned char *aData, size_t aSize) const;
long writeReg(unsigned char aReg, unsigned char *aData, size_t aSize);
long readMsg(unsigned char *aWData, unsigned char aWriteSize, unsigned char *aRData, size_t aReadSize);
long readRegByte(unsigned char aReg) const;
long writeRegByte(unsigned char aReg, unsigned char aVal);
protected:
mutable struct as_i2c_device *mDev;
};
#endif // AS_I2C__HPP__
Im using qt-everywhere 4.7 to cross-compile it, how can I do it? (the code is a c++ wrapper from lowlevels c functions).
Regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 Qt 应用程序中将 char 替换为 QChar,将 string 替换为 QString。您需要包含#include 才能使用这些类。
它们是与本机 C/C++ 字符和字符串类等效的类,并且也允许自动类型转换。当您需要调用低级代码时,只需键入将 QChar 转换为 char 并将 QString 转换为字符串即可。
you can replace char with QChar, string with QString in your Qt application. You need to include #include in order to use these classes.
They are equivalent classes to native C/C++ char and string classes and allow automatic typecasting as well. When you need to invoke low level code, you can just type cast QChar to char and QString to string.