Git Product home page Git Product logo

Comments (1)

pezy avatar pezy commented on June 5, 2024
  • frameGeometry: 包含了其父亲(window frame)的边框.
  • geometry: 可以理解为当前widget真正的边框.
  • rect: == (0, 0, width(), height()); 注意与geometry的区别, 它是从左上角开始的边框.

这里重点说明下rect()和geometry()的区别:

看源码:

inline QRect QWidget::rect() const
{ return QRect(0,0,data->crect.width(),data->crect.height()); }

inline const QRect &QWidget::geometry() const
{ return data->crect; }

可以得知它俩都是来自QWidgetData()的成员指针crect. 但区别在于 rect() 始终从坐标原点开始计算。而geometry是根据窗口像素位置来确定的。但两者大小永远一致。这么说可能还是不太清楚。做个简单的实验: 43aec9d

运行一下Playground, 并拖动窗口,看输出。就可以清晰的看出这两者的区别了。

geometry().width() == width();
geometry().height() == height();

其示意图如下图所示:

image

  • contentRect: 边缘内部的边框, 在geometry的内部.
  • normalGeometry: 这个指的是当前widget在正常情况下(没有最大化或全屏)的边框.
  • childrenRect: 获取子widget的边框, 如果没有孩子, 长宽皆为0.

see the debug out at here

from qtlab.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.