本页内容

C

C++ API 变更

已移除的 C++ 函数

在Qt for MCUs 的上一版本中已弃用的所有函数,均已在v2.0中移除。下表列出了这些函数及其替代方案。

已移除替代函数
uchar *DrawingDevice::pixelAt(int32_t x, int32_t y) constQul::PlatformInterface::PixelDataPointer DrawingDevice::pixelDataAt(int32_t x, int32_t y)
uchar *DrawingDevice::pixelAt(Qul::PlatformInterface::Point pos) constQul::PlatformInterface::PixelDataPointer DrawingDevice::pixelDataAt( pos) constQul::PlatformInterface::Point
Qul::PlatformInterface::Texture::dataAtOffset()Qul::PlatformInterface::PixelDataPointer Texture::pixelData(int16_t x, int16_t y) const
int32_t Qul::PlatformInterface::DrawingDevice::bytesPerPixel() constint32_tQul::PlatformInterface::DrawingDevice::bitsPerPixel() const
int8_t Qul::PlatformInterface::Texture::bytesPerPixel() constint8_tQul::PlatformInterface::Texture::bitsPerPixel() const
int Qul::Image::bytesPerPixel() constint Qul::Image::bitsPerPixel() const
Qul::Application::setUiLanguage()Qul::ApplicationSettings

以下示例展示了在Qt for MCUs 2.0 中如何设置应用程序的用户界面语言,并与 1.9 版本进行了对比。

Qt for MCUs v1.9及更早版本
Qul::Application app;
app.setUiLanguage("pl_PL");
Qt for MCUs v2.0及更高版本
Qul::Application app;
app.settings().uiLanguage.setValue("pl_PL");

已修改的 C++ API

Qul::Platform 命名空间

自Qt for MCUs 2.0 起,此前定义在Qul::Platform 命名空间中的函数已移至新的PlatformContext 结构中。各平台实现继承了该新结构,并重写了其虚函数。Qt Quick Ultralite 核心通过Qul::Platform::getPlatformInstance() 函数访问这些平台特定函数。更多信息请参阅PlatformContext 以及Qt Quick Ultralite 《平台移植指南》。

以下是一个关于PlatformContext 与Qt for MCUs 1.9用法对比的示例:

Qt for MCUs v1.9 及更早版本Qt for MCUs v2.0 及更高版本
auto now = Qul::Platform::currentTimestamp();
auto now = Qul::Platform::getPlatformInstance()->currentTimestamp();

在某些 Qt 许可下可用。
了解更多。