当前位置: 首页 > article >正文

Qt example---40000 Chips

结合这个demo来学习图形视图框架,肯定效果很好

    QApplication app(argc, argv);
    app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);

Qt::AA_DontCreateNativeWidgetSiblings
4
Ensures that siblings of native widgets stay non-native unless specifically set by the Qt::WA_NativeWindow attribute.
Native:原生的

Sibling:兄弟

    QSplitter *vSplitter = new QSplitter;
    vSplitter->setOrientation(Qt::Vertical);

 orientation : Qt::Orientation

orientation:方向

splitter:分裂器

side by side:并排的

This property holds the orientation of the splitter

By default, the orientation is horizontal (i.e., the widgets are laid out side by side). The possible orientations are Qt::Horizontal and Qt::Vertical.

Access functions:

Qt::Orientation

orientation() const

void

setOrientation(Qt::Orientation)

            QColor color(image.pixel(int(image.width() * x), int(image.height() * y)));

QRgb QImage::pixel(const QPoint &position) const

pixel:像素

massive:大规模的

manipulation:使用

Returns the color of the pixel at the given position.

If the position is not valid, the results are undefined.

Warning: This function is expensive when used for massive pixel manipulations. Use constBits() or constScanLine() when many pixels needs to be read.

See also setPixel(), valid(), constBits(), constScanLine(), and Pixel Manipulation.

    graphicsView->setRenderHint(QPainter::Antialiasing, false);

QPainter::Antialiasing
0x01
Indicates that the engine should antialias edges of primitives if possible.
 Antialiasing:抗锯齿

antialias:抗锯齿

primitives:图元

edges:边缘

graphicsView->setDragMode(QGraphicsView::RubberBandDrag);

QGraphicsView::RubberBandDrag
2
A rubber band will appear. Dragging the mouse will set the rubber band geometry, and all items covered by the rubber band are selected. This mode is disabled for non-interactive views.

rubber:橡胶

band:带状物

geometry:几何图形

    graphicsView->setOptimizationFlags(QGraphicsView::DontSavePainterState);

 optimizationFlags : OptimizationFlags

 optimization:最优化

tune:调整

performance:执行

flags that can be used to tune QGraphicsView's performance.

extra:额外的

bounding:边界框

certain:确定的

aid:帮助

render:绘制

common case:常见情况

degrade:降低

varies:改变

QGraphicsView uses clipping, extra bounding rect adjustments, and certain other aids to improve rendering quality and performance for the common case graphics scene. However, depending on the target platform, the scene, and the viewport in use, some of these operations can degrade performance.

The effect varies from flag to flag; see the OptimizationFlags documentation for details.

By default, no optimization flags are enabled.

This property was introduced in Qt 4.3.

Access functions:

OptimizationFlags

optimizationFlags() const

void

setOptimizationFlags(OptimizationFlags flags)

See also setOptimizationFlag().

enum QGraphicsView::OptimizationFlag
flags QGraphicsView::OptimizationFlags

This enum describes flags that you can enable to improve rendering performance in QGraphicsView. By default, none of these flags are set. Note that setting a flag usually imposes a side effect, and this effect can vary between paint devices and platforms.

imposes:强制推行

a side effect:副作用


QGraphicsView::DontSavePainterState
0x2
When rendering, QGraphicsView protects the painter state (see QPainter::save()) when rendering the background or foreground, and when rendering each item. This allows you to leave the painter in an altered state (i.e., you can call QPainter::setPen() or QPainter::setBrush() without restoring the state after painting). However, if the items consistently do restore the state, you should enable this flag to prevent QGraphicsView from doing the same.
altered:改变

graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);

 enum QGraphicsView::ViewportUpdateMode

This enum describes how QGraphicsView updates its viewport when the scene contents change or are exposed.

expose:显露


QGraphicsView::SmartViewportUpdate
2
QGraphicsView will attempt to find an optimal update mode by analyzing the areas that require a redraw.

attempt:尝试

optimal:最佳的

    zoomInIcon->setAutoRepeat(true);

 autoRepeat : bool

regular:规律的

intervals:间隔

initial:最初的

This property holds whether autoRepeat is enabled

If autoRepeat is enabled, then the pressed(), released(), and clicked() signals are emitted at regular intervals when the button is down. autoRepeat is off by default. The initial delay and the repetition interval are defined in milliseconds by autoRepeatDelay and autoRepeatInterval.

Note: If a button is pressed down by a shortcut key, then auto-repeat is enabled and timed by the system and not by this class. The pressed(), released(), and clicked() signals will be emitted like in the normal case.

Access functions:

bool

autoRepeat() const

void

setAutoRepeat(bool)

autoRepeatDelay : int

kicks in:开始运作

This property holds the initial delay of auto-repetition

If autoRepeat is enabled, then autoRepeatDelay defines the initial delay in milliseconds before auto-repetition kicks in.

This property was introduced in Qt 4.2.

void QAbstractScrollArea::setViewport(QWidget *widget)

viewport:视口,视窗

Sets the viewport to be the given widget. The QAbstractScrollArea will take ownership of the given widget.

If widget is 0, QAbstractScrollArea will assign a new QWidget instance for the viewport.

This function was introduced in Qt 4.2.

[pure virtual] QRectF QGraphicsItem::boundingRect() const

This pure virtual function defines the outer bounds of the item as a rectangle; all painting must be restricted to inside an item's bounding rect. QGraphicsView uses this to determine whether the item requires redrawing.

arbitrary:随心所欲的

Although the item's shape can be arbitrary, the bounding rect is always rectangular, and it is unaffected by the items' transformation.

notifies:通知

imminent:即将发生的

artifacts:史前古器物

Reimplement:重定义

If you want to change the item's bounding rectangle, you must first call prepareGeometryChange(). This notifies the scene of the imminent change, so that it can update its item geometry index; otherwise, the scene will be unaware of the item's new geometry, and the results are undefined (typically, rendering artifacts are left within the view).

Reimplement this function to let QGraphicsView determine what parts of the widget, if any, need to be redrawn.

compensate:补偿

though:不过

Note: For shapes that paint an outline / stroke, it is important to include half the pen width in the bounding rect. It is not necessary to compensate for antialiasing, though.

Example:

  QRectF CircleItem::boundingRect() const
  {
      qreal penWidth = 1;
      return QRectF(-radius - penWidth / 2, -radius - penWidth / 2,
                    diameter + penWidth, diameter + penWidth);
  }

[virtual] QPainterPath QGraphicsItem::shape() const

Returns the shape of this item as a QPainterPath in local coordinates. The shape is used for many things, including collision detection, hit tests, and for the QGraphicsScene::items() functions.

collision detection:碰撞检测

accurate:精确的

round:圆形的

The default implementation calls boundingRect() to return a simple rectangular shape, but subclasses can reimplement this function to return a more accurate shape for non-rectangular items. For example, a round item may choose to return an elliptic shape for better collision detection. For example:

  QPainterPath RoundItem::shape() const
  {
      QPainterPath path;
      path.addEllipse(boundingRect());
      return path;
  }

The outline of a shape can vary depending on the width and style of the pen used when drawing. If you want to include this outline in the item's shape, you can create a shape from the stroke using QPainterPathStroker.

This function is called by the default implementations of contains() and collidesWithPath().

collides:碰撞


http://www.kler.cn/a/370251.html

相关文章:

  • 什么是报文的大端和小端,有没有什么记忆口诀?
  • 二叉树--堆排序
  • [Qt]事件-鼠标事件、键盘事件、定时器事件、窗口改变事件、事件分发器与事件过滤器
  • 低代码系统-产品架构案例介绍(五)
  • 网络安全:信息时代的守护者
  • k8s集群安装
  • XCode16中c++头文件找不到解决办法
  • 007:无人机遥控器功能介绍
  • 鼠标事件与webGl坐标系
  • RayLink为企业提供高效安全的远程办公环境
  • 架构师备考-非关系型数据库
  • 贵州鑫宏远农业-始终致力于推动现代农业的科技创新与发展
  • 使用 FastGPT + Ollama 搭建本地 AI 客服小助手
  • 【封装小程序log,设定层级】
  • opencv - py_ml - py_kmeans
  • Vue.js从入门到精通 — 基础知识
  • 医学影像基础:常见的医学影像学术语和概念
  • 商场应急管理:SpringBoot技术解决方案
  • 后端:Spring-1
  • 智能EDA小白从0开始 —— DAY30 冉谱微RFIC-GPT
  • canvas基础学习(鼠标点位拖拽)
  • 为什么有的说法是STM32有60个外部中断,有的说法是有23个中断
  • vscode中提升效率的插件扩展——待更新
  • 基于Distil-Whisper的实时ASR【自动语音识别】
  • python实战项目47:Selenium采集百度股市通数据
  • 电商 API 接口:提升用户体验的关键路径深度解析