CString 在 Qt 应用程序中的使用

发布于 2024-11-24 02:53:05 字数 940 浏览 0 评论 0原文

我想使用我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

和我恋爱吧 2024-12-01 02:53:05

您可以在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文