QRCode 组件 — sgcHTML | eSeGeCe

QRCode

TsgcHTMLComponent_QRCode — 从任意文本或 URL 渲染纯 Pascal 实现的 ISO/IEC 18004 SVG 二维码,可选择纠错等级,适用于 Delphi、C++ Builder 和 .NET。

TsgcHTMLComponent_QRCode

设置 DataECCLevel,然后读取 HTML 属性 — 或调用 Build 单行方法,一行代码即可完成。

组件类

TsgcHTMLComponent_QRCode

渲染为

内联 SVG 二维码 + 可选说明文字(纯 Pascal 编码器)

语言

Delphi, C++ Builder, .NET

设置数据内容,渲染它

设置 Data,选择 ECCLevel,然后读取 HTML — 或调用静态辅助方法 Build

uses
  sgcHTML_Component_QRCode;

var
  oQR: TsgcHTMLComponent_QRCode;
  sHTML: string;
begin
  oQR := TsgcHTMLComponent_QRCode.Create(nil);
  try
    oQR.Data := 'https://www.esegece.com';
    oQR.ECCLevel := qrHigh;
    oQR.ModuleSize := 6;
    oQR.Caption := 'Scan to open';
    oQR.CaptionVisible := True;

    WebModule.Response := oQR.HTML;   // SVG QR modules + optional caption
  finally
    oQR.Free;
  end;
end;

// One-liner for inline use inside a bigger page:
sHTML := TsgcHTMLComponent_QRCode.Build('https://www.esegece.com', qrHigh, 6);
// includes: sgcHTML_Component_QRCode.hpp

TsgcHTMLComponent_QRCode *oQR = new TsgcHTMLComponent_QRCode(NULL);
try
{
  oQR->Data = "https://www.esegece.com";
  oQR->ECCLevel = qrHigh;
  oQR->ModuleSize = 6;
  oQR->Caption = "Scan to open";
  oQR->CaptionVisible = true;

  String html = oQR->HTML;   // SVG QR modules + optional caption
}
__finally
{
  delete oQR;
}
using esegece.sgcWebSockets;

var qr = new TsgcHTMLComponent_QRCode();
qr.Data = "https://www.esegece.com";
qr.ECCLevel = TsgcHTMLQRECCLevel.qrHigh;
qr.ModuleSize = 6;
qr.Caption = "Scan to open";
qr.CaptionVisible = true;

string html = qr.HTML;   // SVG QR modules + optional caption

关键属性与方法

您最常使用的成员。

数据内容

Data 保存要编码的文本或 URL;编码器会自动选择数字、字母数字或字节模式,以及能容纳数据的最小版本(1–40)。

纠错等级

ECCLevelqrLow/qrMedium/qrQuartile/qrHigh)在符号尺寸与抗损坏能力之间进行权衡。

模块尺寸与静区

ModuleSize 设置每个模块的像素大小;QuietZone 以模块为单位控制空白边框。

颜色

DarkColor/LightColor 用于重新设置模块和背景的颜色;请保持足够的对比度以确保可扫描。

说明文字

Caption/CaptionVisible 在二维码下方渲染一行可选文字。

单行方法

类函数 Build(aData, aECCLevel, aModuleSize) 无需管理实例即可返回可用的 HTML。

继续探索

在线帮助此组件的完整 API 参考和使用指南。
所有 sgcHTML 组件浏览 80 多个组件的完整功能矩阵。
下载免费试用版30 天试用版附带 60.HTML 演示项目。
价格Single、Team 和 Site 授权,均含完整源代码。

准备好开始了吗?

下载免费试用版,开始在 Delphi、C++ Builder 和 .NET 中构建 Web 界面。