- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
因此,例如,当我在 QLabel 上使用 setText() 时,Qt 会自动为我更新 View /gui 并显示新文本,但幕后发生了什么?在使用 setText() 等函数时,是否有自动调用的更新函数?
谢谢!!
最佳答案
您应该查看此 link 中的基本文档.
内部系统稍微复杂一点,但总的来说,它遵循观察者模式。这种机制允许检测用户 Action 或改变状态,并响应这个 Action 。
低级交互,如刷新屏幕,是通过 Event System 实现的
In Qt, events are objects, derived from the abstract QEvent class, that represent things that have happened either within an application or as a result of outside activity that the application needs to know about. Events can be received and handled by any instance of a QObject subclass, but they are especially relevant to widgets. This document describes how events are delivered and handled in a typical application.
所以,关于显示过程,有一个专门的事件。 QWidget 对象处理/订阅 PaintEvent,参见 QWidget::paintEvent
.
This event handler can be reimplemented in a subclass to receive paint events passed in event. A paint event is a request to repaint all or part of a widget.
当您调用 QLineEdit::setText()
时,将在下次触发显示事件时根据操作系统配置、刷新率等重新绘制小部件。
对于高级交互,Qt 使用基于 signal/slot 的类似模式机制:
Observer pattern is used everywhere in GUI applications and often leads to some boilerplate code. Qt was created with the idea of removing this boilerplate code and providing a nice and clean syntax, and the signal and slots mechanism is the answer.
关于c++ - View 如何在幕后更新?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55258746/
对于要执行的JS代码,由解析器逐行解析,如果代码无效,则显示错误信息。如果一切正确,那么解析器会生成一个称为抽象语法树的数据结构。然后使用此抽象语法树为解释器生成字节码以供执行。 以上快速分析可以总结
似乎如果我在 () 中包装一个字符串、 bool 值或数字原始值,我会得到一个包装原始值的字符串、 bool 值、数字对象。这个结论正确吗? 此外,似乎 () 对于字符串和 bool 值是可选的,但对
我有几个关于 Java 中的嵌套类的问题。 关于内存分配,嵌套类是如何“隐藏”的? 您不能在嵌套类中声明静态变量(我认为确切的错误是静态属性只能在顶级类中声明)。为什么会这样?嵌套类还有哪些其他限制?
对于没有使用 Lambda Expresstions 经验的人,下面的代码让它看起来很神奇: int totalScore = File.ReadLines(@"c:/names.txt")
一个朴素的类型系统会将对象存储为指向其类型的指针(其中包含许多有用的信息,如 vtable、对象大小等),然后是其数据。如果.Net 有这样的类型系统,object在 32 位系统上占用 4 个字节,
我有以下用于字符串加密和解密的JAVA代码: public class AES { private SecretKeySpec setKey(String myKey) {
我试图了解 React 中的“组件”。 我有几个问题,所以我认为社区是提出问题的最佳场所。 1 - 当我们这样做时: var foo = React.createClass ({ ... }); Co
我想知道 ref 和 out 关键字在幕后是如何工作的?例如,如果我们在方法上使用它,它会把这个值类型变量放入某个类中以便像使用引用类型一样使用它吗? 最佳答案 in order to work wi
我对 Rails ActiveRecord、Doctrine for PHP(以及类似的 ORM)背后的一些设计很感兴趣。 ORM 如何设法实现链式访问器等功能,它们通常需要多深的工作? ORM 如何
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: C# “as” cast vs classic cast 我想知道当我做类似的事情时,.Net CLR 的底
好吧,这似乎是一个菜鸟问题,但我认识的许多 Web 开发人员都没有完全理解这个问题。 基本上,如何使用 FileUpload 控件的上传事件将文件从网页文件输入框上传到网络服务器(例如托管 .net
我很熟悉,按下返回键会导致 activity 被“销毁”,或者当开发人员调用函数 finish() 时,或者当系统需要时内存等... 并且还熟悉我们需要在 onDestroy 中执行清理过程,例如 u
我正在使用 GameViewController 和 GameScene。这个链接到 GameScene.sks。在 GameViewController 中,我将 aspect radio 设置为
关于 EF 的另一个问题: 我想知道在遍历查询结果时幕后发生了什么。 例如,查看以下代码: var activeSources = from e in entitiesContext.Sources
你好,我有一个关于 d3 的性质的问题,我认为这是关于 d3 的非常深入的细节。 据我了解, d3 中的变量声明,如 var svg = d3.select('boby').append('svg'
我是一名优秀的程序员,十分优秀!