Qt:玩转QPainter序列九(文本,文本框,填充)

news2024/9/20 9:49:02

前言

继续承接序列八

正文

在这里插入图片描述
在这里插入图片描述

1. drawImage系列函数 绘制图像

inline void drawImage(const QPoint &p, const QImage &image);

  • 作用: 在指定的点 p 上绘制 QImage 图像。图像的左上角将对齐到 p 点。

inline void drawImage(int x, int y, const QImage &image, int sx = 0, int sy = 0, int sw = -1, int sh = -1, Qt::ImageConversionFlags flags = Qt::AutoColor);

  • 作用:QImage 中的指定区域绘制图像。
  • 参数:
    • x, y: 图像绘制的起始位置。
    • image: 要绘制的图像。
    • sx, sy: 源图像中要绘制区域的起始点。
    • sw, sh: 源图像中要绘制区域的宽度和高度。如果为负数,表示使用整个图像。
    • flags: 图像转换标志(如颜色模式)。

Qt::ImageConversionFlags 的用途

  • 格式转换: 当你绘制的图像格式与目标设备的显示格式不一致时,ImageConversionFlags 决定了图像转换的方式。例如,从彩色图像转换为单色图像时,可以指定是否使用抖动处理。

  • 颜色模式: 可以选择只使用彩色部分、单色部分或者自动选择。例如:

    Qt::AutoColor: 自动选择合适的颜色模式。
    Qt::MonoOnly: 只显示单色部分。
    Qt::ColorOnly: 只显示彩色部分。

  • 抖动处理: 对于低色深的设备或者图像,可以通过 ImageConversionFlags 来选择不同的抖动处理方式(例如有序抖动、阈值抖动、扩散抖动等)。

示例

void PlayQPainter::initcboImageFlag()
{
    //添加所有的Qt::ImageConversionFlags
    ui->cboImageFlag->addItem("ColorMode_Mask",static_cast<int>(Qt::ColorMode_Mask));
    ui->cboImageFlag->addItem("AutoColor",static_cast<int>(Qt::AutoColor));
    ui->cboImageFlag->addItem("ColorOnly",static_cast<int>(Qt::ColorOnly));
    ui->cboImageFlag->addItem("MonoOnly",static_cast<int>(Qt::MonoOnly));
    ui->cboImageFlag->addItem("AlphaDither_Mask",static_cast<int>(Qt::AlphaDither_Mask));
    ui->cboImageFlag->addItem("ThresholdAlphaDither",static_cast<int>(Qt::ThresholdAlphaDither));
    ui->cboImageFlag->addItem("OrderedAlphaDither",static_cast<int>(Qt::OrderedAlphaDither));
    ui->cboImageFlag->addItem("DiffuseAlphaDither",static_cast<int>(Qt::DiffuseAlphaDither));
    ui->cboImageFlag->addItem("NoAlpha",static_cast<int>(Qt::NoAlpha));
    ui->cboImageFlag->addItem("Dither_Mask",static_cast<int>(Qt::Dither_Mask));
    ui->cboImageFlag->addItem("DiffuseDither",static_cast<int>(Qt::DiffuseDither));
    ui->cboImageFlag->addItem("OrderedDither",static_cast<int>(Qt::OrderedDither));
    ui->cboImageFlag->addItem("ThresholdDither",static_cast<int>(Qt::ThresholdDither));
    ui->cboImageFlag->addItem("DitherMode_Mask",static_cast<int>(Qt::DitherMode_Mask));
    ui->cboImageFlag->addItem("AutoDither",static_cast<int>(Qt::AutoDither));
    ui->cboImageFlag->addItem("PreferDither",static_cast<int>(Qt::PreferDither));
    ui->cboImageFlag->addItem("AvoidDither",static_cast<int>(Qt::AvoidDither));
    ui->cboImageFlag->addItem("NoOpaqueDetection",static_cast<int>(Qt::NoOpaqueDetection));
    ui->cboImageFlag->addItem("NoFormatConversion",static_cast<int>(Qt::NoFormatConversion));

    //连接信号与槽
    connect(ui->cboImageFlag,QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](){
        int index = ui->cboImageFlag->currentIndex();
        Qt::ImageConversionFlag style = (Qt::ImageConversionFlag)ui->cboImageFlag->itemData(index).toInt();
        ui->paintArea->setImageFlag(style);
    });
}

void PaintWidget::paintEvent(QPaintEvent* event)
{
    Q_UNUSED(event);

    QPainter painter(this);
    // 设置抗锯齿
    painter.setRenderHint(QPainter::Antialiasing, true);
    // 设置粗一点
    QPen pen;
    pen.setWidth(3);
    painter.setPen(pen);
    // 加载图像到 QPixmap,替换为你的图片路径
    QImage image("D:/all_the_code/qt_code/ts/playQPainter/t1.png");
    painter.drawImage(30,50,image,0,0,-1,-1,Qt::MonoOnly);
}

在这里插入图片描述

2.文本布局函数

void setLayoutDirection(Qt::LayoutDirection direction);

  • 作用: 设置绘制文本的布局方向(如从左到右或从右到左)。
  • 参数:
    • direction:布局方向,有LeftToRight(左到右), RightToLeft(右到左), LayoutDirectionAuto(自动)

Qt::LayoutDirection layoutDirection() const;

  • 作用: 返回当前的布局方向。

3. 绘制字形序列

void drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun);

  • 作用: 绘制一个 QGlyphRun,这是一个用于在高级文本排版中表示字形序列的类。
  • 参数:
    • position: 绘制字形的起始位置。
    • glyphRun: 包含字形序列的 QGlyphRun 对象。

例子

void PaintWidget::paintEvent(QPaintEvent* event)
{
    Q_UNUSED(event);

    QPainter painter(this);
    // 设置抗锯齿
    painter.setRenderHint(QPainter::Antialiasing, true);
    // 设置字体
     QFont font("Times New Roman", 36);
     QRawFont rawFont = QRawFont::fromFont(font);

     // 创建 QGlyphRun 对象
     QGlyphRun glyphRun;
     glyphRun.setRawFont(rawFont);

     // 需要绘制的文本
     QString text = "Qt GlyphRun Test";

     // 生成字形索引和位置
     QVector<quint32> glyphIndexes;
     QVector<QPointF> positions;
     double x = 0;

     for (QChar ch : text) {
         // 获取每个字符的字形索引
         glyphIndexes.append(rawFont.glyphIndexesForString(QString(ch)).at(0));

         // 计算每个字形的位置
         positions.append(QPointF(x, 0));

         // 获取字形的横向进位,并更新 x 坐标偏移
         QVector<QPointF> advances = rawFont.advancesForGlyphIndexes(glyphIndexes);
         x += advances.last().x();
     }

     glyphRun.setGlyphIndexes(glyphIndexes);
     glyphRun.setPositions(positions);

     // 绘制位置,指定基线位置
     QPointF position(50, 100);

     // 使用 drawGlyphRun 绘制字形
     painter.drawGlyphRun(position, glyphRun);
}

在这里插入图片描述

4.drawStaticText系列函数 绘制静态文本

drawStaticText 函数用于绘制静态文本,静态文本在绘制时不会重新进行布局或重绘。因此,它适用于那些文本内容不会频繁变化且需要高效绘制的场景。

  • void drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText);

    • 作用: 在指定的浮点坐标 topLeftPosition 处绘制 QStaticText 对象。
    • 参数:
      • topLeftPosition: 绘制起点的浮点坐标。
      • staticText: 要绘制的静态文本对象,类型为 QStaticText
  • inline void drawStaticText(const QPoint &topLeftPosition, const QStaticText &staticText);

    • 作用: 在指定的整数坐标 topLeftPosition 处绘制 QStaticText 对象。
  • inline void drawStaticText(int left, int top, const QStaticText &staticText);

    • 作用: 在指定的 (left, top) 坐标处绘制 QStaticText 对象。
3. 区别
  • 性能:

    • drawStaticText 的性能比 drawText 更高,因为它假设文本不会改变,因此可以缓存布局结果,避免每次绘制时重新计算布局。
    • drawText 每次绘制时都会重新计算文本的布局,适合文本内容动态变化的场景。
  • 用途:

    • drawStaticText 适用于绘制不经常变化的文本,如静态标签、标题等,特别是在需要反复绘制相同文本时,它的性能优势更明显。
    • drawText 则适合绘制内容可能频繁变化的文本,如用户输入的文字、实时数据显示等。
  • 文本类型:

    • drawStaticText 使用的是 QStaticText 类型,这个类型设计用于静态文本,并为静态文本的高效绘制做了优化。
    • drawText 使用的是 QString 类型,适用于一般的文本绘制。

例子

void PaintWidget::paintEvent(QPaintEvent* event)
{
    Q_UNUSED(event);

    QPainter painter(this);
    // 设置抗锯齿
    painter.setRenderHint(QPainter::Antialiasing, true);
    // 设置字体
    QFont font("Arial", 14);
    painter.setFont(font);

    // 定义 QStaticText 对象
    QStaticText staticText("Hello, QStaticText!");

    // 使用 QPoint 指定的整数坐标 (50, 50) 处绘制文本
    QPoint topLeftPosition(50, 50);
    painter.drawStaticText(topLeftPosition, staticText);

    // 使用整数值指定的 (200, 100) 处绘制文本
    painter.drawStaticText(200, 100, staticText);
}

在这里插入图片描述

5. drawText系列函数 绘制文本

drawText 函数用于绘制普通文本,但是绘制时每次都会进行文本的布局计算。这使得它适合绘制内容可能频繁变化的动态文本。

  • void drawText(const QPointF &p, const QString &s);

    • 作用: 在指定的点 p 上绘制文本 s
    • 参数:
      • p: 文本绘制的起始位置。
      • s: 要绘制的字符串。
  • inline void drawText(const QPoint &p, const QString &s);

    • 作用: 在指定的点 p 上绘制文本 s
  • inline void drawText(int x, int y, const QString &s);

    • 作用: 在指定的点 (x, y) 上绘制文本 s
  • void drawText(const QPointF &p, const QString &str, int tf, int justificationPadding);

    • 作用:在指定的点 p 绘制字符串 str,并且可以使用文本标志 tf 和对齐填充 justificationPadding 来控制文本的对齐和填充效果。 justificationPadding 表示两个字符串之间的举例,它越大,两个单词之间距离越大。
  • void drawText(const QRectF &r, int flags, const QString &text, QRectF *br = nullptr);

    • 作用:在矩形区域 r 内绘制字符串 text,文本的对齐方式由 flags 参数指定。可以选择性地返回文本的实际边界矩形 br
  • void drawText(const QRect &r, int flags, const QString &text, QRect *br = nullptr);

    • 作用:与上一个函数类似,只是使用了整数类型的 QRect 代替浮
  • inline void drawText(int x, int y, int w, int h, int flags, const QString &text, QRect *br = nullptr);

    • 作用:在指定的矩形区域 (x, y, w, h) 内绘制字符串 text,并根据 flags 参数控制文本的对齐方式。可以选择性地返回文本的实际边界矩形 br
  • void drawText(const QRectF &r, const QString &text, const QTextOption &o = QTextOption());

    • 作用:在矩形区域 r 内绘制字符串 text,文本的格式由 QTextOption 对象 o 指定。QTextOption 提供了更细粒度的文本格式控制选项,例如文本对齐、换行模式、方向等。
    • 参数
      • QRectF &r:文本绘制的矩形区域。
      • QString &text:要绘制的文本内容。
      • QTextOption &o:文本选项,控制文本的格式和行为。

例子

void PaintWidget::paintEvent(QPaintEvent* event)
{
    Q_UNUSED(event);

    QPainter painter(this);
    // 设置抗锯齿
    painter.setRenderHint(QPainter::Antialiasing, true);
    // 设置字体
    QFont font("Arial", 14);
    painter.setFont(font);

    // 测试 drawText(const QPointF &p, const QString &str, int tf, int justificationPadding)
    // justificationPadding越大,两个单词之间间距越大
    QPointF point1(20, 30);
    painter.drawText(point1, "QPointF drawText", Qt::AlignLeft, 30);

    // 测试 drawText(const QRect &r, int flags, const QString &text, QRect *br = nullptr)
    QRect rect1(20, 50, 200, 40);
    painter.drawRect(rect1); // 画出矩形边框
    painter.drawText(rect1, Qt::AlignCenter | Qt::TextWordWrap, "QRect drawText");

    // 测试 inline void drawText(int x, int y, int w, int h, int flags, const QString &text, QRect *br = nullptr)
    painter.drawText(20, 100, 200, 40, Qt::AlignRight | Qt::AlignVCenter, "x, y, w, h drawText");

    // 测试 drawText(const QRectF &r, const QString &text, const QTextOption &o = QTextOption())
    QRectF rectF1(20, 150, 200, 100);
    QTextOption option;
    option.setAlignment(Qt::AlignLeft);
    option.setWrapMode(QTextOption::WordWrap);
    painter.drawText(rectF1, "QRectF drawText with QTextOption", option);
}


在这里插入图片描述

6.boundingRect系列函数 计算绘制文本所需要的边界矩形

QPainter 类中,boundingRect 函数用于计算绘制文本所需的边界矩形。

QRectF boundingRect(const QRectF &rect, int flags, const QString &text);

  • 作用: 计算在给定的矩形 rect 内,绘制文本 text 所需的边界矩形。
  • 参数:
    • rect: 用于计算文本边界矩形的矩形区域。这个矩形定义了文本绘制的区域。
    • flags: 用于指定文本布局的标志,通常为 Qt::TextFlags,例如 Qt::AlignLeftQt::AlignRightQt::AlignCenter 等,用于控制文本的对齐方式。
    • text: 要绘制的文本字符串。
  • 返回: 返回一个 QRectF 对象,表示文本绘制所需的边界矩形。

QRect boundingRect(const QRect &rect, int flags, const QString &text);

  • 作用: 计算在给定的矩形 rect 内,绘制文本 text 所需的边界矩形。

inline QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text);

  • 作用: 计算在给定的矩形区域内,绘制文本 text 所需的边界矩形。
  • 参数:
    • x, y: 矩形区域的左上角坐标。
    • w, h: 矩形区域的宽度和高度。
    • flags: 文本布局标志。
    • text: 要绘制的文本字符串。
  • 返回: 返回一个 QRect 对象,表示文本绘制所需的边界矩形。

QRectF boundingRect(const QRectF &rect, const QString &text, const QTextOption &o = QTextOption());

  • 作用: 计算在给定的矩形 rect 内,绘制文本 text 所需的边界矩形,并考虑文本选项。
  • 参数:
    • rect: 用于计算文本边界矩形的矩形区域,类型为 QRectF
    • text: 要绘制的文本字符串。
    • o: QTextOption 对象,用于设置文本的格式选项,例如对齐方式、换行策略等。如果未提供,则使用默认选项。
  • 返回: 返回一个 QRectF 对象,表示文本绘制所需的边界矩形。

例子

void PaintWidget::paintEvent(QPaintEvent* event)
{
    Q_UNUSED(event);

    QPainter painter(this);
    // 设置抗锯齿
    painter.setRenderHint(QPainter::Antialiasing, true);
    // 设置字体
    QFont font("Arial", 14);
    painter.setFont(font);

    // 文本和标志
    QString text = "Hello, boundingRect!";
    int flags = Qt::AlignLeft | Qt::AlignTop; // 文本对齐方式

    // 第一个重载函数: 使用 QRect 参数
    QRect rect(50, 50, 200, 50);
    QRect boundingRect1 = painter.boundingRect(rect, flags, text);
    painter.drawRect(boundingRect1);
    painter.drawText(rect, flags, text);

    // 第二个重载函数: 使用 (x, y, w, h) 参数
    QRect boundingRect2 = painter.boundingRect(300, 50, 200, 50, flags, text);
    painter.drawRect(boundingRect2);
    painter.drawText(boundingRect2, flags, text);

    // 第三个重载函数: 使用 QRectF 和 QTextOption 参数
    QRectF rectF(50, 150, 200, 50);
    QTextOption textOption(Qt::AlignLeft);
    QRectF boundingRect3 = painter.boundingRect(rectF, text, textOption);
    painter.drawRect(boundingRect3.toRect());
    painter.drawText(boundingRect3, text);
}

在这里插入图片描述

7.drawTextItem系列函数

QPainter 类中的 drawTextItem 函数用于绘制 QTextItem 对象。QTextItem 是一个文本项,包含了文本的布局信息和渲染信息。

void drawTextItem(const QPointF &p, const QTextItem &ti);

  • 作用: 使用 QTextItem 对象在指定的位置绘制文本项。

inline void drawTextItem(int x, int y, const QTextItem &ti);

  • 作用: 使用 QTextItem 对象在指定的坐标位置绘制文本项。

inline void drawTextItem(const QPoint &p, const QTextItem &ti);

  • 作用: 使用 QTextItem 对象在指定的 QPoint 位置绘制文本项。

例子

void PaintWidget::paintEvent(QPaintEvent* event)
{
    Q_UNUSED(event);

    QPainter painter(this);
    // 设置抗锯齿
    painter.setRenderHint(QPainter::Antialiasing, true);
    // 设置字体和文本内容
    QFont font("Arial", 24);
    QString text = "Hello, Qt!";

    // 创建 QTextLayout 并设置其文本和字体
    QTextLayout textLayout(text, font);
    textLayout.beginLayout();

    // 创建一个 QTextLine
    QTextLine line = textLayout.createLine();
    line.setPosition(QPointF(0, 0));

    // 完成布局
    textLayout.endLayout();

    // 使用 QTextItem 绘制文本项
    for (int i = 0; i < textLayout.lineCount(); ++i) {
        QTextLine line = textLayout.lineAt(i);

        // 计算绘制位置
         QPointF position(50, 100 + i * line.height());

         // 在指定的位置绘制该行的文本
         line.draw(&painter, position);
    }
}

在这里插入图片描述

8. fillRect系列函数 填充矩形

  • void fillRect(const QRectF &rect, const QBrush &brush):

    • 作用: 使用 QBrush 对象填充指定的矩形区域 rectQRectF 是一个浮点矩形,表示矩形区域可以有小数值坐标。
  • inline void fillRect(int x, int y, int w, int h, const QBrush &brush):

    • 作用: 使用 QBrush 对象填充从 (x, y) 开始的宽度为 w,高度为 h 的矩形区域。
  • void fillRect(const QRect &rect, const QBrush &brush):

    • 作用: 使用 QBrush 对象填充整数坐标矩形 rect
  • void fillRect(const QRectF &rect, const QColor &color):

    • 作用: 使用 QColor 对象指定的颜色填充浮点矩形区域 rect
  • inline void fillRect(int x, int y, int w, int h, const QColor &color):

    • 作用: 使用 QColor 对象指定的颜色填充从 (x, y) 开始的宽度为 w,高度为 h 的矩形区域。
  • void fillRect(const QRect &rect, const QColor &color):

    • 作用: 使用 QColor 对象指定的颜色填充整数坐标矩形 rect
  • inline void fillRect(int x, int y, int w, int h, Qt::GlobalColor c):

    • 作用: 使用 Qt 的预定义颜色 Qt::GlobalColor 填充从 (x, y) 开始的宽度为 w,高度为 h 的矩形区域。
  • inline void fillRect(const QRect &r, Qt::GlobalColor c):

    • 作用: 使用 Qt 的预定义颜色 Qt::GlobalColor 填充整数坐标矩形 r
  • inline void fillRect(const QRectF &r, Qt::GlobalColor c):

    • 作用: 使用 Qt 的预定义颜色 Qt::GlobalColor 填充浮点矩形 r
  • inline void fillRect(int x, int y, int w, int h, Qt::BrushStyle style):

    • 作用: 使用 Qt::BrushStyle 枚举指定的样式填充从 (x, y) 开始的宽度为 w,高度为 h 的矩形区域。
  • inline void fillRect(const QRect &r, Qt::BrushStyle style):

    • 作用: 使用 Qt::BrushStyle 枚举指定的样式填充整数坐标矩形 r
  • inline void fillRect(const QRectF &r, Qt::BrushStyle style):

    • 作用: 使用 Qt::BrushStyle 枚举指定的样式填充浮点矩形 r
  • inline void fillRect(int x, int y, int w, int h, QGradient::Preset preset):

    • 作用: 使用 QGradient::Preset 预设的渐变填充从 (x, y) 开始的宽度为 w,高度为 h 的矩形区域。
  • inline void fillRect(const QRect &r, QGradient::Preset preset):

    • 作用: 使用 QGradient::Preset 预设的渐变填充整数坐标矩形 r
  • inline void fillRect(const QRectF &r, QGradient::Preset preset):

    • 作用: 使用 QGradient::Preset 预设的渐变填充浮点矩形 r

例子

void PaintWidget::paintEvent(QPaintEvent* event)
{
    Q_UNUSED(event);

    QPainter painter(this);
    // 设置抗锯齿
    painter.setRenderHint(QPainter::Antialiasing, true);
    // 使用 QBrush 填充矩形
    QBrush brush(Qt::DiagCrossPattern);
    QRect rect1(10, 10, 100, 50);
    painter.fillRect(rect1, brush);

    // 使用 QColor 填充矩形
    QColor color(Qt::blue);
    QRect rect2(120, 10, 100, 50);
    painter.fillRect(rect2, color);

    // 使用 Qt::GlobalColor 填充矩形
    QRect rect3(230, 10, 100, 50);
    painter.fillRect(rect3, Qt::red);

    // 使用 QGradient::Preset 填充矩形
    QRect rect4(10, 70, 100, 50);
    painter.fillRect(rect4, QGradient::RadialGradient);

    // 使用 Qt::BrushStyle 填充矩形
    QRect rect5(120, 70, 100, 50);
    painter.fillRect(rect5, Qt::Dense7Pattern);
}

在这里插入图片描述

9.eraseRect系列函数

QPainter 类中的 eraseRect 函数用于擦除矩形区域的内容。具体来说,这些函数会将指定区域的绘图内容清除,通常将其填充为背景色或透明。以下是每个 eraseRect 函数的详细解释:

void eraseRect(const QRectF &rect);

  • 作用: 擦除 QRectF 类型的矩形区域。
  • 参数:
    • rect: QRectF 类型,指定要擦除的矩形区域。QRectF 支持浮点坐标,因此可以用于更高精度的绘图区域。

inline void eraseRect(int x, int y, int w, int h);

  • 作用: 擦除指定位置和尺寸的矩形区域。参数为整数值。

inline void eraseRect(const QRect &rect);

  • 作用: 擦除 QRect 类型的矩形区域。

例子

void PaintWidget::paintEvent(QPaintEvent* event)
{
    Q_UNUSED(event);

    QPainter painter(this);
    // 设置抗锯齿
    painter.setRenderHint(QPainter::Antialiasing, true);
    // 设置背景为白色
    painter.fillRect(rect(), Qt::white);

    // 绘制一个蓝色的矩形
    painter.fillRect(20, 20, 200, 100, Qt::blue);

    // 使用 eraseRect 擦除指定区域
    // 擦除 (50, 40) 开始的宽度为 80,高度为 50 的矩形区域
    painter.eraseRect(50, 40, 80, 50);

    // 绘制一个红色的矩形
    painter.fillRect(250, 20, 200, 100, Qt::red);

    // 使用 eraseRect 擦除 QRect 类型的矩形区域
    QRect rect(280, 40, 80, 50);
    painter.eraseRect(rect);
}

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2095504.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

若依 Vue3的前后端分离系统管理 创建

RuoYi 若依官方网站 |后台管理系统|权限管理系统|快速开发框架|企业管理系统|开源框架|微服务框架|前后端分离框架|开源后台系统|RuoYi|RuoYi-Vue|RuoYi-Cloud|RuoYi框架|RuoYi开源|RuoYi视频|若依视频|RuoYi开发文档|若依开发文档|Java开源框架|Java|SpringBoot|SrpingBoot2.0…

【JPCS独立出版】第四届电气工程与计算机技术国际学术会议(ICEECT 2024,9月27-29)

第四届电气工程与计算机技术国际学术会议&#xff08;ICEECT2024&#xff09;将于9月27日-29日在哈尔滨举办。 会议主要围绕"电路与系统"、“电气工程材料”、“计算机视觉”、“计算机技术”等专业研究领域展开讨论。旨在为气工程、计算机技术等领域的专家学者及企业…

Java EE

Java EE 包含JavaSE 增加一些新的API 构建一个后端服务 网页->web服务器->java后端 web后端(javaEE)程序需要运行在服务器中的&#xff0c;这样前端才可以访问得到 服务器&#xff1a;是容器&#xff0c;是连接用户和程序之间的中间件 解释1&#xff1a;一款软件&#…

HBase 部署及shell操作

HBase 数据库 一、HBase 概述1.1 HBase 是什么HBase 的特点 二、HBase 模型及架构2.1 HBase 逻辑模型2.2 HBase 数据模型2.3 HBase 物理模型2.3.1 列簇物理模型2.3.2 Rowkey 字段排序2.3.3 Region 存储到不同节点2.3.4 Region 结构 2.4 HBase 基本架构 三、搭建 HBase 分布式集…

【Linux】线程结束

目录 线程安全和重入 死锁 STL中的容器不是线程安全的 线程安全的单例模式 自旋锁 读者写者问题 线程安全和重入 线程安全&#xff1a;多个线程并发执行同一段代码时&#xff0c;不会出现不同的&#xff08;异常的&#xff09;结果&#xff0c;我们就说线程是安全的。常见…

如何学好文件操作,快来看这篇文章(沉淀中)!!!!

文章目录 1. 为什么使用文件&#xff1f;2. 什么是文件&#xff1f;2.1 程序文件2.2 数据文件2.3 文件名 3. ⼆进制文件和文本文件&#xff1f;4. 文件的打开和关闭4.1 流和标准流4.1.1 流4.1.2 标准流 4.2 文件指针4.3 文件的打开和关闭 5. ⽂件的顺序读写5.1 顺序读写函数介绍…

jQuery库

注明&#xff1a;本文参考自&#xff1a;jQuery - 白月黑羽 (byhy.net) jQuery安装 Download jQuery | jQuery下载到本地 ps: script标签中的src属性&#xff1a;表示包含要执行的代码的外部文件位置 <!DOCTYPE html> <html lang"en"><head><s…

unity游戏开放:标记物体 一目了然

Unity游戏开发:标记物体,让开发变得一目了然 “好读书&#xff0c;不求甚解&#xff1b;每有会意&#xff0c;便欣然忘食。” 本文目录&#xff1a; Unity游戏开发 Unity游戏开发:标记物体,让开发变得一目了然前言1. 什么是Tag&#xff1f;2. Unity中如何添加和管理Tag步骤1&am…

vue如何引入element-ui

2.x用element-ui 3.x用element-plus https://blog.csdn.net/weixin_41207479/article/details/127066333 引入element-ui的三种方式

点餐API接口对接的过程中需要注意哪些问题

以下是点餐 API 接口对接的一般步骤&#xff1a; 选择合适的点餐 API 服务提供商&#xff1a;市面上有不少提供点餐 API 的平台。你需要根据自身业务需求、预算、接口的稳定性和性能、技术支持等因素来综合考量选择。注册与申请&#xff1a;在选定 API 服务提供商后&#xff0…

数据响应式

响应式原理 课堂主题 1.利用defineProperty实现数据劫持2.利用ES6中proxy实现数据劫持3.实现数据驱动视图更新&#xff0c;实现数据响应4.发布订阅模式 知识点 defineProperty&#xff1b;Proxy代理数据劫持发布订阅观察者模式与发布订阅数据响应式 defineProperty Objec…

Junit单元测试入门

目录 一、单元测试 1.1 基本概念 1.2 以往测试存在的问题和不足 二、快速入门 2.1 基本步骤 2.2 基本使用示例&#xff08;vscode为例&#xff09; 2.2 断言机制&#xff08;重要&#xff09; 2.3 其它注解 一、单元测试 1.1 基本概念 针对最小单元的测试&#xff0c…

集成电路学习:什么是CPU中央处理器

一、CPU&#xff1a;中央处理器 CPU&#xff0c;全称Central Processing Unit&#xff0c;即中央处理器&#xff0c;是计算机系统的核心部件&#xff0c;负责执行程序指令&#xff0c;完成数据的算术运算或逻辑运算等任务。它是计算机中最重要的硬件之一&#xff0c;相当于计算…

【Qt 事件】—— 详解Qt事件处理

目录 &#xff08;一&#xff09;事件介绍 &#xff08;二&#xff09;事件的处理 &#xff08;三&#xff09;按键事件 3.1 单个按键 3.2 组合按键 &#xff08;四&#xff09;鼠标事件 4.1 鼠标单击事件 4.2 鼠标释放事件 4.3 鼠标双击事件 4.4 鼠标移动事件 4.5…

【Redis】Redis 典型应⽤ - 缓存 (cache)

Redis 典型应⽤ - 缓存 cache 什么是缓存使⽤ Redis 作为缓存缓存的更新策略1) 定期⽣成2) 实时⽣成 缓存预热, 缓存穿透, 缓存雪崩 和 缓存击穿关于缓存预热 (Cache preheating)关于缓存穿透 (Cache penetration)关于缓存雪崩 (Cache avalanche)关于缓存击穿 (Cache breakdown…

OpenLayers3, 航线动画实现

文章目录 一、前言二、代码实现三、总结 一、前言 本文基于OpenLayers3&#xff0c;实现航线动画的功能。 二、代码实现 <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quo…

题解AtCoder ABC 358 F Easiest Maze

一道模拟题。 思路 最短的路线是直接竖着走下来&#xff0c;经过 n n n 个格子&#xff0c;所以 k k k 最小是 n n n。如果想要延长路线&#xff0c;可以采用九转大肠的形状&#xff0c;就像这样&#xff1a; 可以发现&#xff0c;每次向左走之后都必须走回来&#xff0c;…

关于几道计算机网络题的解答

2017年12月28日&#xff0c;星期四&#xff0c; 照片上的第一题中多项式的指数看不清&#xff0c;但没关系&#xff0c;就现在的情形&#xff0c;说一下大概的思路&#xff0c;参考着再结合题目中实际的参数&#xff0c;再套一遍就能把题目解出来了&#xff0c; 假设&#xf…

JS 如何判断是否是IE浏览器

例子 if(!!window.ActiveXObject || "ActiveXObject" in window){alert("抱歉&#xff0c;不支持IE浏览器&#xff01;");return; }

kafka使用

异步发送数据 package com.shf.kafka.producer; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.serializa…