首页 > 其他分享 >three.js基础之几何体Curve、Geometry

three.js基础之几何体Curve、Geometry

时间:2024-04-05 16:46:14浏览次数:26  
标签:... const Geometry Curve THREE 几何体 geometry new 50

Curve

EllipseCurve

<canvas id="EllipseCurve" width="300px" height="200px"></canvas>
<canvas id="ArcCurve" width="300px" height="200px"></canvas>
<canvas id="CurvePath" width="300px" height="200px"></canvas>
<canvas id="SplineCurve-CatmullRomCurve3" width="300px" height="200px"></canvas>
<canvas id="QuadraticBezierCurve" width="300px" height="200px"></canvas>
<canvas id="QuadraticBezierCurve3" width="300px" height="200px"></canvas>

<script type="importmap">
  {
    "imports": {
      "three": "./js/build/three.module.js",
      "three/jsm/": "./js/jsm/"
    }
  }
</script>
<script type="module">
  import * as THREE from "three";

  {
    const renderer = new THREE.WebGLRenderer({
      canvas: document.getElementById("EllipseCurve"),
    });
    renderer.setClearColor(0x000000);

    const scene = new THREE.Scene();

    const ellipse = new THREE.EllipseCurve(0, 0, 50, 20, 0, 2 * Math.PI, false); // 参数:椭圆中心坐标x、y、x方向半径、y方向半径、开始角度、结束角度、是否为顺时针绘制
    const pointsArr = ellipse.getPoints(50); //分段数50,返回51个顶点
    console.log("曲线上获取坐标", pointsArr);
    const pointsArr2 = ellipse.getSpacedPoints(50); //按照曲线长度等间距返回顶点数据
    console.log("曲线上获取坐标", pointsArr2);

    const geometry = new THREE.BufferGeometry(); //创建一个几何体对象
    geometry.setFromPoints(pointsArr); //读取坐标数据赋值给几何体顶点
    const geometry2 = new THREE.BufferGeometry();
    geometry2.setFromPoints(pointsArr2);
    const lineMaterial = new THREE.LineBasicMaterial({
      color: 0xffffff,
    });
    const line = new THREE.Line(geometry, lineMaterial); // 线模型
    const line2 = new THREE.Line(geometry2, lineMaterial);
    line2.position.set(0, 50, 0);
    scene.add(line);
    scene.add(line2);

    const pointsMaterial = new THREE.PointsMaterial({
      color: 0xff00ff,
      size: 5, //点对象像素尺寸
    });
    const points = new THREE.Points(geometry, pointsMaterial); // 点模型
    const points2 = new THREE.Points(geometry2, pointsMaterial);
    points.position.set(0, -30, 0);
    points2.position.set(0, -50, 0);
    scene.add(points);
    scene.add(points2);

    const camera = new THREE.PerspectiveCamera(30, 300 / 200, 1, 3000); //透视投影相机参数设置
    camera.position.set(0, 0, 300);
    camera.lookAt(0, 0, 0);
    scene.add(camera);

    const axesHelper = new THREE.AxesHelper(150);
    scene.add(axesHelper);

    renderer.render(scene, camera);
  }

</script>

ArcCurve

<script>
    ...

    const scene = new THREE.Scene();
    const arc = new THREE.ArcCurve(0, 0, 50, 0, 1.5 * Math.PI, false);
    const pointsArr = arc.getPoints(50);
    const geometry = new THREE.BufferGeometry();
    geometry.setFromPoints(pointsArr);
    const material = new THREE.LineBasicMaterial({
      color: 0xffffff,
    });
    const line = new THREE.Line(geometry, material);
    scene.add(line);

    ...
</script>

CurvePath

<script>
    ...

    //组合曲线
    const R = 20; //圆弧半径
    const H = 100; //直线部分高度
    const line1 = new THREE.LineCurve(new THREE.Vector2(R, H), new THREE.Vector2(R, 0));
    const arc = new THREE.ArcCurve(0, 0, R, 0, Math.PI, true);
    const line2 = new THREE.LineCurve(new THREE.Vector2(-R, 0), new THREE.Vector2(-R, H));
    // CurvePath创建一个组合曲线对象
    const curvePath = new THREE.CurvePath();
    curvePath.curves.push(line1, arc, line2); //拼接出来一个U型轮廓曲线
    const pointsArr = curvePath.getPoints(16); //组合曲线上获取点
    const geometry = new THREE.BufferGeometry();
    geometry.setFromPoints(pointsArr); //读取坐标数据赋值给几何体顶点
    const material = new THREE.LineBasicMaterial({
      color: 0xffffff,
    });
    const line = new THREE.Line(geometry, material);
    line.position.set(0, -30, 0);
    scene.add(line);

    ...
</script>

SplineCurve、CatmullRomCurve3

<script>
    ...

    const arr_2 = [new THREE.Vector2(-50, 0), new THREE.Vector2(0, 30), new THREE.Vector2(50, 0)];
    // 二维样条曲线
    const curve_2 = new THREE.SplineCurve(arr_2);
    const pointsArr_2 = curve_2.getPoints(100);
    const geometry_2 = new THREE.BufferGeometry();
    geometry_2.setFromPoints(pointsArr_2);
    const material = new THREE.LineBasicMaterial({
      color: 0x99ffff,
    });
    const line_2 = new THREE.Line(geometry_2, material);
    line_2.position.set(0, 0, 0);
    scene.add(line_2);

    const arr_3 = [new THREE.Vector3(-50, 0, 0), new THREE.Vector3(0, 30, 0), new THREE.Vector3(50, 0, 0), new THREE.Vector3(0, 0, 80), new THREE.Vector3(0, 0, 0)];
    // 三维样条曲线
    const curve_3 = new THREE.CatmullRomCurve3(arr_3);
    const pointsArr_3 = curve_3.getPoints(100);
    const geometry_3 = new THREE.BufferGeometry();
    geometry_3.setFromPoints(pointsArr_3);
    const line_3 = new THREE.Line(geometry_3, material);
    line_3.position.set(0, 30, 0);
    scene.add(line_3);

    ...
    camera.position.set(100, 100, 300);

    ...
</script>

QuadraticBezierCurve

<script>
    ...

  // p1、p4是曲线起始点,p2、p3是曲线的控制点
    const p1 = new THREE.Vector2(-50, 0);
    const p2 = new THREE.Vector2(-20, 50);
    const p3 = new THREE.Vector2(20, 30);
    const p4 = new THREE.Vector2(50, 0);
    // 二维二次贝赛尔曲线
    const curve_2 = new THREE.QuadraticBezierCurve(p1, p2, p4);
    const pointsArr_2 = curve_2.getPoints(100);
    const geometry_2 = new THREE.BufferGeometry();
    geometry_2.setFromPoints(pointsArr_2);
    const material = new THREE.LineBasicMaterial({
      color: 0x22ff00,
    });
    const line_2 = new THREE.Line(geometry_2, material);
    line_2.position.set(0, 0, 0);
    scene.add(line_2);

    // 二维三次贝赛尔曲线
    const curve_3 = new THREE.QuadraticBezierCurve(p1, p2, p3, p4);
    const pointsArr_3 = curve_3.getPoints(100);
    const geometry_3 = new THREE.BufferGeometry();
    geometry_3.setFromPoints(pointsArr_3);
    const material1 = new THREE.LineBasicMaterial({
      color: 0xffff00,
    });
    const line_3 = new THREE.Line(geometry_3, material1);
    line_3.position.set(0, 30, 0);
    scene.add(line_3);

    ...
    camera.position.set(0, 0, 300);

    ...
</script>

三次贝塞尔曲线似乎有点问题:

 

QuadraticBezierCurve3

<script>
    ...

    // p1、p4是曲线起始点,p2、p3是曲线的控制点
    const p1 = new THREE.Vector3(-80, 0, 0);
    const p2 = new THREE.Vector3(-40, 50, 0);
    const p3 = new THREE.Vector3(50, 50, 0);
    const p4 = new THREE.Vector3(80, 0, 100);
    // 三维二次贝赛尔曲线
    const curve_2 = new THREE.QuadraticBezierCurve3(p1, p2, p4);
    const pointsArr_2 = curve_2.getPoints(100);
    const geometry_2 = new THREE.BufferGeometry();
    geometry_2.setFromPoints(pointsArr_2);
    const material = new THREE.LineBasicMaterial({
      color: 0x22ffff,
    });
    const line_2 = new THREE.Line(geometry_2, material);
    line_2.position.set(0, 0, 0);
    scene.add(line_2);

    // 三维三次贝赛尔曲线
    const curve_3 = new THREE.CubicBezierCurve3(p1, p2, p3, p4);
    const pointsArr_3 = curve_3.getPoints(100);
    const geometry_3 = new THREE.BufferGeometry();
    geometry_3.setFromPoints(pointsArr_3);
    const line_3 = new THREE.Line(geometry_3, material);
    line_3.position.set(0, 30, 0);
    scene.add(line_3);

    ...
    camera.position.set(100, 100, 300);
   
    ...
</script>

Geometry

BufferGeometry

所有几何体的基类

<canvas id="BufferGeometry" width="300px" height="200px"></canvas>
<canvas id="BoxGeometry" width="300px" height="200px"></canvas>
<canvas id="SphereGeometry" width="300px" height="200px"></canvas>
<canvas id="CylinderGeometry" width="300px" height="200px"></canvas>
<canvas id="PlaneGeometry" width="300px" height="200px"></canvas>
<canvas id="CircleGeometry" width="300px" height="200px"></canvas>
<canvas id="ShapeGeometry" width="300px" height="200px"></canvas>
<canvas id="TubeGeometry" width="300px" height="200px"></canvas>
<canvas id="LatheGeometry" width="300px" height="200px"></canvas>
<canvas id="ExtrudeGeometry" width="300px" height="200px"></canvas>
<canvas id="ExtrudeGeometry-path" width="300px" height="200px"></canvas>
<canvas id="EdgesGeometry" width="300px" height="200px"></canvas>
<script type="importmap">
  {
    "imports": {
      "three": "./js/build/three.module.js",
      "three/jsm/": "./js/jsm/"
    }
  }
</script>
<script type="module">
  import * as THREE from "three";

  {
    const renderer = new THREE.WebGLRenderer({
      canvas: document.getElementById("BufferGeometry"),
    });
    renderer.setClearColor(0x000000);

    const scene = new THREE.Scene();

    const material = new THREE.LineBasicMaterial({
      color: 0xffffff,
    });

    const geometry1 = new THREE.BufferGeometry();
    const R = 20;
    const N = 50;
    const sp = (2 * Math.PI) / N;
    const arr = [];
    const cx = 20;
    const cy = 20;
    for (let i = 0; i < N; i++) {
      const angle = sp * i;
      const x = cx + R * Math.cos(angle);
      const y = cy + R * Math.sin(angle);
      arr.push(x, 0, y);
    }
    const vertices1 = new Float32Array(arr);
    const attribue1 = new THREE.BufferAttribute(vertices1, 3);
    geometry1.attributes.position = attribue1;
    const line1 = new THREE.LineLoop(geometry1, material);
    scene.add(line1);

    const geometry2 = new THREE.BufferGeometry();
    // 三维向量表示的坐标值
    const pointsArr2 = [new THREE.Vector3(0, 0, 0), new THREE.Vector3(0, 30, 0), new THREE.Vector3(0, 30, 30), new THREE.Vector3(0, 0, 30)];
    geometry2.setFromPoints(pointsArr2);
    const line2 = new THREE.LineLoop(geometry2, material);
    scene.add(line2);

    const geometry3 = new THREE.BufferGeometry();
    // 二维向量表示的坐标值
    const pointsArr3 = [new THREE.Vector2(0, 0), new THREE.Vector2(50, 0), new THREE.Vector2(50, 50), new THREE.Vector2(0, 50)];
    geometry3.setFromPoints(pointsArr3);
    const line3 = new THREE.LineLoop(geometry3, material);
    scene.add(line3);

    const camera = new THREE.PerspectiveCamera(50, 300 / 200, 1, 3000); //透视投影相机参数设置
    camera.position.set(200, 200, 200);
    camera.lookAt(0, 0, 0);
    scene.add(camera);

    const axesHelper = new THREE.AxesHelper(150);
    scene.add(axesHelper);

    renderer.render(scene, camera);
  }

</script>

BoxGeometry

以下所有几何体的渲染器、相机、坐标轴辅助设置均相同,代码就不重复贴上了。

<script>
    ...

    //长方体
    const geometry = new THREE.BoxGeometry(60, 40, 20);
    const material = new THREE.MeshBasicMaterial({
      color: 0xffffff, //设置材质颜色
      transparent: true, //开启透明
      opacity: 0.5, //设置透明度
    });
    const mesh = new THREE.Mesh(geometry, material);
    mesh.position.set(0, 0, 0);
    scene.add(mesh);

    ...
</script>

SphereGeometry

<script>
    ...

    //球体
    const geometry = new THREE.SphereGeometry(20);
    const material = new THREE.MeshBasicMaterial({
      color: 0xffffff,
    });
    const mesh = new THREE.Mesh(geometry, material);
    scene.add(mesh);

    ...
</script>

CylinderGeometry

<script>
    ...

    //圆柱
    const mesh = new THREE.Mesh(
      new THREE.CylinderGeometry(20, 20, 30),
      new THREE.MeshBasicMaterial({
        color: 0x00ffff,
      })
    );
    scene.add(mesh);

    ...
</script>

PlaneGeometry

<script>
    ...

    //矩形平面
    const mesh = new THREE.Mesh(
      new THREE.PlaneGeometry(50, 30),
      new THREE.MeshBasicMaterial({
        color: 0xffffff,
        side: THREE.DoubleSide, //两面可见
      })
    );
    scene.add(mesh);

    ...
</script>

CircleGeometry

<script>
    ...

  //圆形平面
    const mesh = new THREE.Mesh(
      new THREE.CircleGeometry(30),
      new THREE.MeshBasicMaterial({
        color: 0xffffff,
        side: THREE.DoubleSide, //两面可见
      })
    );
    scene.add(mesh);

    ...
</script>

 

ShapeGeometry

<script>
    ...

    // 平面多边形轮廓
    const shape = new THREE.Shape([new THREE.Vector2(-50, -50), new THREE.Vector2(-50, 50), new THREE.Vector2(50, 50), new THREE.Vector2(50, -50)]);
    const geometry = new THREE.ShapeGeometry(shape);
    const material = new THREE.MeshBasicMaterial({
      color: 0xffffff,
      side: THREE.DoubleSide,
    });
    const mesh = new THREE.Mesh(geometry, material);
    scene.add(mesh);

    // 平面轮廓  arc
    const shape1 = new THREE.Shape();
    shape1.moveTo(0, 0);
    shape1.lineTo(30, 0); // 绘制直线线段
    shape1.arc(0, 0, 50, 0, Math.PI / 2); //圆心坐标是相对于当前currentPoint,而不是坐标原点
    shape1.lineTo(0, 50);
    const geometry1 = new THREE.ShapeGeometry(shape1);
    const material1 = new THREE.MeshBasicMaterial({
      color: 0xff0000,
      side: THREE.DoubleSide,
    });
    const mesh1 = new THREE.Mesh(geometry1, material1);
    mesh1.position.set(0, 100, 0);
    scene.add(mesh1);

    // 平面轮廓  absarc
    const shape2 = new THREE.Shape();
    shape1.moveTo(0, 0);
    shape2.lineTo(100, 0);
    shape2.absarc(100, 0, 50, 0, Math.PI / 2); // absarc圆心坐标不受到currentPoint影响,以坐标原点作为参考
    shape2.lineTo(0, 50);
    const path2_1 = new THREE.Path(); // 圆孔
    path2_1.absarc(25, 25, 20);
    const path2_2 = new THREE.Path(); // 圆孔
    path2_2.absarc(80, 25, 20);
    shape2.holes.push(path2_1, path2_2); //内孔轮廓分别放入holes属性中
    const geometry2 = new THREE.ShapeGeometry(shape2);
    const material2 = new THREE.MeshBasicMaterial({
      color: 0x0000ff,
      side: THREE.DoubleSide,
    });
    const mesh2 = new THREE.Mesh(geometry2, material2);
    mesh2.position.set(0, -150, 0);
    scene.add(mesh2);

    ...
    camera.position.set(0, 0, 1000);

    ...
</script>

<script>
    ...

    const pointsArr = [new THREE.Vector2(0, 0), new THREE.Vector2(60, 0), new THREE.Vector2(30, 45)];
    const shape = new THREE.Shape(pointsArr);
    // 轮廓填充几何体
    const geometry = new THREE.ShapeGeometry(shape);
    const material = new THREE.MeshBasicMaterial({
      color: 0xffffff,
      side: THREE.DoubleSide,
    });
    const mesh = new THREE.Mesh(geometry, material);
    scene.add(mesh);

    ...
</script>

 

TubeGeometry

<script>
    ...

    const p1 = new THREE.Vector3(0, 0, 100);
    const p2 = new THREE.Vector3(0, 0, 30);
    const p3 = new THREE.Vector3(0, 0, 0);
    const p4 = new THREE.Vector3(30, 0, 0);
    const p5 = new THREE.Vector3(100, 0, 0);
    const line1 = new THREE.LineCurve3(p1, p2); // 3D直线线段
    const curve = new THREE.QuadraticBezierCurve3(p2, p3, p4); // 三维二次贝塞尔曲线
    const line2 = new THREE.LineCurve3(p4, p5);
    const curvePath = new THREE.CurvePath();
    curvePath.curves.push(line1, curve, line2); // 三条线拼接为一条曲线
    //管道几何体
    const geometry = new THREE.TubeGeometry(curvePath, 50, 15, 25); //参数:路径、沿着轨迹细分数、管道半径、管道截面圆细分数
    const material = new THREE.MeshBasicMaterial({
      color: 0xffffff,
      side: THREE.DoubleSide,
    });
    const mesh = new THREE.Mesh(geometry, material);
    scene.add(mesh);

    ...
</script>

 

LatheGeometry 

<script>
    ...

    const pointsArr = [new THREE.Vector2(50, 60), new THREE.Vector2(25, 0), new THREE.Vector2(50, -60)];
    // 旋转成型几何体
    const geometry = new THREE.LatheGeometry(pointsArr);
    const material = new THREE.MeshBasicMaterial({
      color: 0xffffff,
      side: THREE.DoubleSide,
    });
    const mesh = new THREE.Mesh(geometry, material);
    scene.add(mesh);

    ...
</script>

 

ExtrudeGeometry 

<script>
    ...

    const pointsArr = [new THREE.Vector2(-50, -50), new THREE.Vector2(-50, 50), new THREE.Vector2(50, 50), new THREE.Vector2(50, -50)];
    const shape = new THREE.Shape(pointsArr);
    //拉伸造型几何体
    const geometry = new THREE.ExtrudeGeometry(shape, { depth: 20 });
    const material = new THREE.MeshBasicMaterial({
      color: 0xffffff,
      side: THREE.DoubleSide,
    });
    const mesh = new THREE.Mesh(geometry, material);
    scene.add(mesh);

    ...
</script>

 

<script>
    ...

    const shape = new THREE.Shape([new THREE.Vector2(0, 0), new THREE.Vector2(0, 10), new THREE.Vector2(10, 10), new THREE.Vector2(10, 0)]);
    const curve = new THREE.CatmullRomCurve3([new THREE.Vector3(-10, -50, -50), new THREE.Vector3(10, 0, 0), new THREE.Vector3(8, 50, 50), new THREE.Vector3(-5, 0, 100)]);
    //扫描造型几何体
    const geometry = new THREE.ExtrudeGeometry(
      shape, //扫描轮廓
      {
        extrudePath: curve, //扫描轨迹
        steps: 100, //沿着路径细分精度,越大越光滑
      }
    );
    const material = new THREE.MeshBasicMaterial({
      color: 0xffffff,
      side: THREE.DoubleSide,
    });
    const mesh = new THREE.Mesh(geometry, material);
    scene.add(mesh);

    ...
</script>

 

EdgesGeometry

<script>
    ...

    // 平面轮廓  absarc
    const shape = new THREE.Shape();
    shape.lineTo(100, 0);
    shape.absarc(100, 0, 50, 0, Math.PI / 2); // absarc圆心坐标不受到currentPoint影响,以坐标原点作为参考
    shape.lineTo(0, 50);
    const path1 = new THREE.Path(); // 圆孔
    path1.absarc(20, 20, 20);
    const path2 = new THREE.Path(); // 圆孔
    path2.absarc(80, 20, 20);
    shape.holes.push(path1, path2); //内孔轮廓分别放入holes属性中
    const geometry = new THREE.ExtrudeGeometry(shape, {
      depth: 20, //拉伸长度
      bevelEnabled: false, //禁止倒角
      curveSegments: 50,
    });
    const material = new THREE.MeshBasicMaterial({
      color: 0xffffff,
      side: THREE.DoubleSide,
    });
    const mesh = new THREE.Mesh(geometry, material);
    // 模型边界线EdgesGeometry
    const edges = new THREE.EdgesGeometry(geometry);
    const edgesMaterial = new THREE.LineBasicMaterial({
      color: 0x00ffff,
    });
    const line = new THREE.LineSegments(edges, edgesMaterial);
    mesh.add(line);
    scene.add(mesh);

    ...
    camera.position.set(200, 200, 500);
    ...
</script>

 

 

 

 

标签:...,const,Geometry,Curve,THREE,几何体,geometry,new,50
From: https://www.cnblogs.com/caroline2016/p/18115766

相关文章

  • Delving into Sample Loss Curve to Embrace Noisy and Imbalanced Data
    这篇论文:提出了prob-and-allocate训练策略,在prob阶段获得样本损失,在allocate阶段分配样本权重。以[2]的meta-weight-net为Baseline,取名为CurveNet,进行部分改动。另外,这篇论文提供的源码结构混乱,复现难度较大。主要的工作也是基于meta-weight-net,创新的内容有限。但是,这篇文章......
  • WPF Storyboary DoubleAnimationUsingPath PathGeometry
    <Windowx:Class="WpfApp30.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.......
  • 【OpenREALM学习笔记:4】geometry_msgs和tf在项目中的不同作用
    geometry_msgsgeometry_msgs是ROS中用于表示几何信息的消息包。它包含了多种消息类型,用于描述点、向量、变换、姿态(位置和方向)、形状等几何概念。geometry_msgs中的消息类型通常用于在ROS节点之间传递几何数据,例如:geometry_msgs/Point:表示三维空间中的一个点。geometry_......
  • STLExporter 是用于将 Three.js 场景中的几何体数据导出为 STL 格式的类。
    demo案例STLExporter是用于将Three.js场景中的几何体数据导出为STL格式的类。下面是关于STLExporter的入参、出参、方法和属性的讲解:入参(Parameters):scene:THREE.Scene类型的参数,表示要导出为STL格式的Three.js场景对象。出参(ReturnValue):string:......
  • GAMES01 Geometry
    生活中有许多曲面、曲线需要去表示。这里也有许多表示几何的方法:Implicitalgebraicsurfacelevelsetsdistancefunctions...Explicitpointcloudpolygonmeshsubdivision,NURBS...Implicit表达通常,隐式表达被定义为f(x,y,z)=0,其中f(x,y,z)是一个xyz的关系表达式......
  • d3d12龙书阅读----绘制几何体(上)
    d3d12龙书阅读----绘制几何体(上)本节主要介绍了构建一个简单的彩色立方体所需流程与重要的api下面主要结合立方体代码分析本节相关知识顶点输入装配器阶段的输入首先,我们需要定义立方体的八个顶点顶点结构体:structVertex{XMFLOAT3Pos;XMFLOAT4Color;};当然......
  • Lecture 11 Geometry 2 (Curves and Surfaces)
    Lecture11Geometry2(CurvesandSurfaces)Curves曲线BézierCurves贝塞尔曲线用一系列控制点定义摸一个曲线,这些控制点会定义曲线满足的一些性质图中通过三个控制点,可以定义曲线起始点和结束点一定在\(p_0\)和\(p_3\)上,并且起始的切线和结束的切线一定都是\(p_0p_1\)......
  • Lecture 10 Geometry 1 (Introduction)
    Lecture10Geometry1(Introduction)Examplesofgeometry几何的例子不同形状的几何光滑的曲面复杂的模型、位置摆放布料水滴城市(复杂在东西多)怎么存储怎么渲染这么大级别的东西离得远的情况下如何简化几何模型如何利用光线之间的连续性毛发微观几何树枝......
  • Qt中关于setGeometry()函数的问题
    setGeometry是相对于父窗体来说的一种对子窗体进行位置设置的方法。当我用在不同的窗体的时候发现有不同的形式QMainWindow和QWidget都是相对父窗体来说的,可是QDialog用上这个设置位置的函数,却是相对于桌面而言的。但是按照道理,他们都是继承的QWidget,setGeometry这个函数的功能......
  • Qt QWindowsWindow::setGeometryDp: Unable to set geometry问题
    总结原因:由于子窗口和父窗口的大小关系不健康,导致父窗口resize失败,失败后会自定义大小解决方法:首先,修改父窗口尺寸,保证其大小可以容纳子部件,可以使用setFixSize()之类的函数修改父窗口尺寸。其次,一定要保证修改父窗口尺寸的函数是放在窗口布局代码之前,如图,我的setIn......