This repository has been archived by the owner on May 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dtk-widget-danchorsbase.html
547 lines (542 loc) · 55.1 KB
/
dtk-widget-danchorsbase.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- danchors.cpp -->
<title>DAnchorsBase Class | Dtk Reference Documentation 1.0.0</title>
<link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
<script type="text/javascript">
document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
// loading style sheet breaks anchors that were jumped to before
// so force jumping to anchor again
setTimeout(function() {
var anchor = location.hash;
// need to jump to different anchor first (e.g. none)
location.hash = "#";
setTimeout(function() {
location.hash = anchor;
}, 0);
}, 0);
</script>
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<ul>
<li><a href="index.html">Dtk Doc</a></li>
<li><a href="index.html">Dtk Reference Documentation</a></li>
<li>DAnchorsBase</li>
<li id="buildversion"><a href="index.html">Qt 5.15.2 Reference Documentation</a></li>
</ul>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#public-slots">Public Slots</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#margin-offset">margin_offset 锚定的间隔和偏移</a></li>
<li class="level2"><a href="#loop-anchor">loop_anchor 判断循环锚定的方式</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">DAnchorsBase Class</h1>
<span class="small-subtitle">class <a href="dtk.html">Dtk</a>::<a href="dtk-widget.html">Widget</a>::DAnchorsBase</span>
<!-- $$$DAnchorsBase-brief -->
<p>DAnchorsBase 提供了一种指定 <a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a> 与其它 <a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a> 之间的关系来确定 其位置的方法. <a href="#details">More...</a></p>
<!-- @@@DAnchorsBase -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <DAnchorsBase></span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherited By:</td><td class="memItemRight bottomAlign"> <p><a href="dtk-widget-danchors.html">Dtk::Widget::DAnchors</a></p>
</td></tr></table></div><ul>
<li><a href="dtk-widget-danchorsbase-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#AnchorError-enum">AnchorError</a></b> { NoError, Conflict, TargetInvalid, PointInvalid, LoopBind }</td></tr>
</table></div>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<div class="table"><table class="propsummary">
<tr><td class="topAlign"><ul>
<li class="fn"><b><a href="dtk-widget-danchorsbase.html#bottomMargin-prop">bottomMargin</a></b> : int</li>
<li class="fn"><b><a href="dtk-widget-danchorsbase.html#centerIn-prop">centerIn</a></b> : QWidget*</li>
<li class="fn"><b><a href="dtk-widget-danchorsbase.html#enabled-prop">enabled</a></b> : bool</li>
<li class="fn"><b><a href="dtk-widget-danchorsbase.html#fill-prop">fill</a></b> : QWidget*</li>
<li class="fn"><b><a href="dtk-widget-danchorsbase.html#horizontalCenterOffset-prop">horizontalCenterOffset</a></b> : int</li>
<li class="fn"><b><a href="dtk-widget-danchorsbase.html#leftMargin-prop">leftMargin</a></b> : int</li>
</ul></td><td class="topAlign"><ul>
<li class="fn"><b><a href="dtk-widget-danchorsbase.html#margins-prop">margins</a></b> : int</li>
<li class="fn"><b><a href="dtk-widget-danchorsbase.html#rightMargin-prop">rightMargin</a></b> : int</li>
<li class="fn"><b><a href="dtk-widget-danchorsbase.html#target-prop">target</a></b> : QWidget* const</li>
<li class="fn"><b><a href="dtk-widget-danchorsbase.html#topMargin-prop">topMargin</a></b> : int</li>
<li class="fn"><b><a href="dtk-widget-danchorsbase.html#verticalCenterOffset-prop">verticalCenterOffset</a></b> : int</li>
</ul>
</td></tr>
</table></div>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#DAnchorsBase">DAnchorsBase</a></b>(QWidget *<i>w</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#dtor.DAnchorsBase">~DAnchorsBase</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#alignWhenCentered-prop">alignWhenCentered</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#bottomMargin-prop">bottomMargin</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QWidget *</td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#centerIn-prop">centerIn</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#enabled-prop">enabled</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Dtk::Widget::DEnhancedWidget *</td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#enhancedWidget">enhancedWidget</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Dtk::Widget::DAnchorsBase::AnchorError </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#errorCode">errorCode</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#errorString">errorString</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QWidget *</td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#fill-prop">fill</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#horizontalCenterOffset-prop">horizontalCenterOffset</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#isBinding">isBinding</a></b>(const Dtk::Widget::DAnchorInfo *<i>info</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#leftMargin-prop">leftMargin</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#margins-prop">margins</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#rightMargin-prop">rightMargin</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QWidget *</td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#target-prop">target</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#topMargin-prop">topMargin</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#verticalCenterOffset-prop">verticalCenterOffset</a></b>() const</td></tr>
</table></div>
<a name="public-slots"></a>
<h2 id="public-slots">Public Slots</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#moveBottom">moveBottom</a></b>(int <i>arg</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#moveCenter">moveCenter</a></b>(const QPoint &<i>arg</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#moveHorizontalCenter">moveHorizontalCenter</a></b>(int <i>arg</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#moveLeft">moveLeft</a></b>(int <i>arg</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#moveRight">moveRight</a></b>(int <i>arg</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#moveTop">moveTop</a></b>(int <i>arg</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#moveVerticalCenter">moveVerticalCenter</a></b>(int <i>arg</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#alignWhenCentered-prop">setAlignWhenCentered</a></b>(bool <i>alignWhenCentered</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#bottomMargin-prop">setBottomMargin</a></b>(int <i>bottomMargin</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#setCenterIn-1">setCenterIn</a></b>(Dtk::Widget::DAnchorsBase *<i>centerIn</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#centerIn-prop">setCenterIn</a></b>(QWidget *<i>centerIn</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#enabled-prop">setEnabled</a></b>(bool <i>enabled</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#setFill-1">setFill</a></b>(Dtk::Widget::DAnchorsBase *<i>fill</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#fill-prop">setFill</a></b>(QWidget *<i>fill</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#horizontalCenterOffset-prop">setHorizontalCenterOffset</a></b>(int <i>horizontalCenterOffset</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#leftMargin-prop">setLeftMargin</a></b>(int <i>leftMargin</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#margins-prop">setMargins</a></b>(int <i>margins</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#rightMargin-prop">setRightMargin</a></b>(int <i>rightMargin</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#topMargin-prop">setTopMargin</a></b>(int <i>topMargin</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#verticalCenterOffset-prop">setVerticalCenterOffset</a></b>(int <i>verticalCenterOffset</i>)</td></tr>
</table></div>
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#alignWhenCentered-prop">alignWhenCenteredChanged</a></b>(bool <i>alignWhenCentered</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#bottomChanged">bottomChanged</a></b>(const Dtk::Widget::DAnchorInfo *<i>bottom</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#bottomMarginChanged">bottomMarginChanged</a></b>(int <i>bottomMargin</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#centerInChanged">centerInChanged</a></b>(QWidget *<i>centerIn</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#enabledChanged">enabledChanged</a></b>(bool <i>enabled</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#fillChanged">fillChanged</a></b>(QWidget *<i>fill</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#horizontalCenterChanged">horizontalCenterChanged</a></b>(const Dtk::Widget::DAnchorInfo *<i>horizontalCenter</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#horizontalCenterOffsetChanged">horizontalCenterOffsetChanged</a></b>(int <i>horizontalCenterOffset</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#leftChanged">leftChanged</a></b>(const Dtk::Widget::DAnchorInfo *<i>left</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#leftMarginChanged">leftMarginChanged</a></b>(int <i>leftMargin</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#marginsChanged">marginsChanged</a></b>(int <i>margins</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#rightChanged">rightChanged</a></b>(const Dtk::Widget::DAnchorInfo *<i>right</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#rightMarginChanged">rightMarginChanged</a></b>(int <i>rightMargin</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#topChanged">topChanged</a></b>(const Dtk::Widget::DAnchorInfo *<i>top</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#topMarginChanged">topMarginChanged</a></b>(int <i>topMargin</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#verticalCenterChanged">verticalCenterChanged</a></b>(const Dtk::Widget::DAnchorInfo *<i>verticalCenter</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#verticalCenterOffsetChanged">verticalCenterOffsetChanged</a></b>(int <i>verticalCenterOffset</i>)</td></tr>
</table></div>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#clearAnchors">clearAnchors</a></b>(const QWidget *<i>w</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Dtk::Widget::DAnchorsBase *</td><td class="memItemRight bottomAlign"><b><a href="dtk-widget-danchorsbase.html#getAnchorBaseByWidget">getAnchorBaseByWidget</a></b>(const QWidget *<i>w</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$DAnchorsBase-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>除了比较传统的布局方式之外,DtkWidget 还提供了一种使用锚定概念布局控件的方法( 类似于 QQuickItem 中的 anchors 属性),可以认为每个控件具有一组6个不可见的“锚 线”:left,horizontalCenter,right,top,verticalCenter和bottom,如图所示:</p>
<p class="centerAlign"><img src="images/edges_anchors.png" alt="" /></p><p>使用 <a href="dtk-widget-danchors.html">DAnchors</a> 可以让 <a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a> 基于这些“锚线”来确定相互间的关系,如:</p>
<pre class="cpp">
DAnchors<span class="operator"><</span><span class="type"><a href="http://doc.qt.io/qt-5/qlabel.html">QLabel</a></span><span class="operator">></span> rect1(<span class="keyword">new</span> <span class="type"><a href="http://doc.qt.io/qt-5/qlabel.html">QLabel</a></span>(<span class="string">"rect1"</span>));
DAnchors<span class="operator"><</span><span class="type"><a href="http://doc.qt.io/qt-5/qlabel.html">QLabel</a></span><span class="operator">></span> rect2(<span class="keyword">new</span> <span class="type"><a href="http://doc.qt.io/qt-5/qlabel.html">QLabel</a></span>(<span class="string">"rect2"</span>));
rect2<span class="operator">.</span>setLeft(rect1<span class="operator">.</span>right());
</pre>
<p>这样 rect2 的左边界就会和 rect1 的右边界对齐:</p>
<p class="centerAlign"><img src="images/edge1.png" alt="" /></p><p>另外还可以同时设置多个“锚线”:</p>
<pre class="cpp">
DAnchors<span class="operator"><</span><span class="type"><a href="http://doc.qt.io/qt-5/qlabel.html">QLabel</a></span><span class="operator">></span> rect1(<span class="keyword">new</span> <span class="type"><a href="http://doc.qt.io/qt-5/qlabel.html">QLabel</a></span>(<span class="string">"rect1"</span>));
DAnchors<span class="operator"><</span><span class="type"><a href="http://doc.qt.io/qt-5/qlabel.html">QLabel</a></span><span class="operator">></span> rect2(<span class="keyword">new</span> <span class="type"><a href="http://doc.qt.io/qt-5/qlabel.html">QLabel</a></span>(<span class="string">"rect2"</span>));
rect2<span class="operator">.</span>setTop(rect1<span class="operator">.</span>bottom());
rect2<span class="operator">.</span>setLeft(rect1<span class="operator">.</span>right());
</pre>
<p class="centerAlign"><img src="images/edge3.png" alt="" /></p><p>锚定布局同时在多个控件中使用,控件之间只需要满足以下条件: <i>控件之间为兄弟关系,或被锚定控件为父控件</i> <i>锚定关系不能循环绑定</i></p>
<a name="margin-offset"></a>
<h3 id="margin-offset">margin_offset 锚定的间隔和偏移</h3>
<p>锚定系统允许设置“锚线”之间的间距,和“锚线”一一对应,每个控件都有一组4个 margin: <a href="dtk-widget-danchorsbase.html#leftMargin-prop">leftMargin</a>, <a href="dtk-widget-danchorsbase.html#rightMargin-prop">rightMargin</a>, <a href="dtk-widget-danchorsbase.html#topMargin-prop">topMargin</a> 和 <a href="dtk-widget-danchorsbase.html#bottomMargin-prop">bottomMargin</a> 以及两个 offset: <a href="dtk-widget-danchorsbase.html#horizontalCenterOffset-prop">horizontalCenterOffset</a> 和 <a href="dtk-widget-danchorsbase.html#verticalCenterOffset-prop">verticalCenterOffset</a>。</p>
<p class="centerAlign"><img src="images/margins_anchors.png" alt="" /></p><p>下面是左margin的例子:</p>
<pre class="cpp">
DAnchors<span class="operator"><</span><span class="type"><a href="http://doc.qt.io/qt-5/qlabel.html">QLabel</a></span><span class="operator">></span> rect1(<span class="keyword">new</span> <span class="type"><a href="http://doc.qt.io/qt-5/qlabel.html">QLabel</a></span>(<span class="string">"rect1"</span>));
DAnchors<span class="operator"><</span><span class="type"><a href="http://doc.qt.io/qt-5/qlabel.html">QLabel</a></span><span class="operator">></span> rect2(<span class="keyword">new</span> <span class="type"><a href="http://doc.qt.io/qt-5/qlabel.html">QLabel</a></span>(<span class="string">"rect2"</span>));
rect2<span class="operator">.</span>setLeftMargin(<span class="number">5</span>);
rect2<span class="operator">.</span>setLeft(rect1<span class="operator">.</span>right());
</pre>
<p>rect2 的左边界相距 rect1 的右边界5个像素:</p>
<p class="centerAlign"><img src="images/edge2.png" alt="" /></p><p><b>Note: </b>margin 仅仅是对设置的锚点生效,并不是让控件本身增加了边距,如果设置了 margin,但并没有设置相应的锚点,对控件本身而已是没有任何影响的。margin 的值可以 为负数,通过值的正负来决定margin的方向(内 margin 还是外 margin)</p>
<p>除了基于“锚线”来设置锚定外,另外还有 <a href="dtk-widget-danchorsbase.html#centerIn-prop">setCenterIn</a> 和 <a href="dtk-widget-danchorsbase.html#fill-prop">setFill</a> 这两个比较特殊的 的实现。</p>
<a name="loop-anchor"></a>
<h3 id="loop-anchor">loop_anchor 判断循环锚定的方式</h3>
<p>假设 DAnchorsBase a1, a2; a1.setRight(a2.left()); 则判断 a1 和 a2 之间 会不会存在循环绑定的逻辑为: 尝试更改 a1 右边界的值,更新后如果 a2 左边界的值产出了变化,则认为会导致循环绑 定,否则认为不存在</p>
</div>
<!-- @@@DAnchorsBase -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$AnchorError$$$NoError$$$Conflict$$$TargetInvalid$$$PointInvalid$$$LoopBind -->
<h3 class="fn" id="AnchorError-enum"><a name="AnchorError-enum"></a>enum DAnchorsBase::<span class="name">AnchorError</span></h3>
<p>DAnchorsBase::AnchorError 设置锚定信息的过程中可能出现的错误类型</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>Dtk::Widget::DAnchorsBase::NoError</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">设置锚定的过程中没有任何错误发生</td></tr>
<tr><td class="topAlign"><code>Dtk::Widget::DAnchorsBase::Conflict</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">表示设置的锚定关系跟已有关系存在冲突,如 fill 和 <a href="dtk-widget-danchorsbase.html#centerIn-prop">centerIn</a> 不能同时设置</td></tr>
<tr><td class="topAlign"><code>Dtk::Widget::DAnchorsBase::TargetInvalid</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign">表示设置锚定关系时的目标控件无效</td></tr>
<tr><td class="topAlign"><code>Dtk::Widget::DAnchorsBase::PointInvalid</code></td><td class="topAlign tblval"><code>3</code></td><td class="topAlign">表示设置锚定关系时的“锚线”信息错误,如把 <a href="http://doc.qt.io/qt-5/qt.html#AnchorPoint-enum">Qt::AnchorLeft</a> 设置到了 <a href="http://doc.qt.io/qt-5/qt.html#AnchorPoint-enum">Qt::AnchorTop</a> 上</td></tr>
<tr><td class="topAlign"><code>Dtk::Widget::DAnchorsBase::LoopBind</code></td><td class="topAlign tblval"><code>4</code></td><td class="topAlign">表示设置的锚定关系和已有关系形成了循环绑定</td></tr>
</table></div>
<!-- @@@AnchorError -->
</div>
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$bottomMargin-prop$$$bottomMargin$$$setBottomMarginint$$$bottomMarginChangedint -->
<h3 class="fn" id="bottomMargin-prop"><a name="bottomMargin-prop"></a><span class="name">bottomMargin</span> : <span class="type">int</span></h3>
<p>下“锚线”的边距,优先级高于 margins</p>
<p><b>Note: </b>可读可写</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>bottomMargin</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setBottomMargin</b></span>(int <i>bottomMargin</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="dtk-widget-danchorsbase.html#bottomMarginChanged">bottomMarginChanged</a></b></span>(int <i>bottomMargin</i>)</td></tr>
</table></div>
<!-- @@@bottomMargin -->
<!-- $$$centerIn-prop$$$centerIn$$$setCenterInQWidget*$$$setCenterInDtk::Widget::DAnchorsBase*$$$centerInChangedQWidget* -->
<h3 class="fn" id="centerIn-prop"><a name="centerIn-prop"></a><span class="name">centerIn</span> : <span class="type"><a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a></span>*</h3>
<p>target 控件的居中目标对象</p>
<p><b>Note: </b>可读可写</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QWidget *</td><td class="memItemRight bottomAlign"><span class="name"><b>centerIn</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>setCenterIn</b></span>(QWidget *<i>centerIn</i>)</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="dtk-widget-danchorsbase.html#setCenterIn-1">setCenterIn</a></b></span>(Dtk::Widget::DAnchorsBase *<i>centerIn</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="dtk-widget-danchorsbase.html#centerInChanged">centerInChanged</a></b></span>(QWidget *<i>centerIn</i>)</td></tr>
</table></div>
<!-- @@@centerIn -->
<!-- $$$enabled-prop$$$enabled$$$setEnabledbool$$$enabledChangedbool -->
<h3 class="fn" id="enabled-prop"><a name="enabled-prop"></a><span class="name">enabled</span> : <span class="type">bool</span></h3>
<p>控制锚定功能是否开启,为 false 时仅仅表示不会根据控件各种属性的变化来 来更新它的位置,但锚定关系并没有被解除</p>
<p><b>Note: </b>可读可写</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>enabled</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setEnabled</b></span>(bool <i>enabled</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="dtk-widget-danchorsbase.html#enabledChanged">enabledChanged</a></b></span>(bool <i>enabled</i>)</td></tr>
</table></div>
<!-- @@@enabled -->
<!-- $$$fill-prop$$$fill$$$setFillQWidget*$$$setFillDtk::Widget::DAnchorsBase*$$$fillChangedQWidget* -->
<h3 class="fn" id="fill-prop"><a name="fill-prop"></a><span class="name">fill</span> : <span class="type"><a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a></span>*</h3>
<p>target 控件的填充目标对象</p>
<p><b>Note: </b>可读可写</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QWidget *</td><td class="memItemRight bottomAlign"><span class="name"><b>fill</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>setFill</b></span>(QWidget *<i>fill</i>)</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="dtk-widget-danchorsbase.html#setFill-1">setFill</a></b></span>(Dtk::Widget::DAnchorsBase *<i>fill</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="dtk-widget-danchorsbase.html#fillChanged">fillChanged</a></b></span>(QWidget *<i>fill</i>)</td></tr>
</table></div>
<!-- @@@fill -->
<!-- $$$horizontalCenterOffset-prop$$$horizontalCenterOffset$$$setHorizontalCenterOffsetint$$$horizontalCenterOffsetChangedint -->
<h3 class="fn" id="horizontalCenterOffset-prop"><a name="horizontalCenterOffset-prop"></a><span class="name">horizontalCenterOffset</span> : <span class="type">int</span></h3>
<p>水平“锚线”的偏移量</p>
<p><b>Note: </b>可读可写</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>horizontalCenterOffset</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setHorizontalCenterOffset</b></span>(int <i>horizontalCenterOffset</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="dtk-widget-danchorsbase.html#horizontalCenterOffsetChanged">horizontalCenterOffsetChanged</a></b></span>(int <i>horizontalCenterOffset</i>)</td></tr>
</table></div>
<!-- @@@horizontalCenterOffset -->
<!-- $$$leftMargin-prop$$$leftMargin$$$setLeftMarginint$$$leftMarginChangedint -->
<h3 class="fn" id="leftMargin-prop"><a name="leftMargin-prop"></a><span class="name">leftMargin</span> : <span class="type">int</span></h3>
<p>左“锚线”的边距,优先级高于 margins</p>
<p><b>Note: </b>可读可写</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>leftMargin</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setLeftMargin</b></span>(int <i>leftMargin</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="dtk-widget-danchorsbase.html#leftMarginChanged">leftMarginChanged</a></b></span>(int <i>leftMargin</i>)</td></tr>
</table></div>
<!-- @@@leftMargin -->
<!-- $$$margins-prop$$$margins$$$setMarginsint$$$marginsChangedint -->
<h3 class="fn" id="margins-prop"><a name="margins-prop"></a><span class="name">margins</span> : <span class="type">int</span></h3>
<p>上下左右四条“锚线”的边距,此值的优先级低于每条“锚线”特定的 margin 值</p>
<p><b>Note: </b>可读可写</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>margins</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setMargins</b></span>(int <i>margins</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="dtk-widget-danchorsbase.html#marginsChanged">marginsChanged</a></b></span>(int <i>margins</i>)</td></tr>
</table></div>
<!-- @@@margins -->
<!-- $$$rightMargin-prop$$$rightMargin$$$setRightMarginint$$$rightMarginChangedint -->
<h3 class="fn" id="rightMargin-prop"><a name="rightMargin-prop"></a><span class="name">rightMargin</span> : <span class="type">int</span></h3>
<p>右“锚线”的边距,优先级高于 margins</p>
<p><b>Note: </b>可读可写</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>rightMargin</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setRightMargin</b></span>(int <i>rightMargin</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="dtk-widget-danchorsbase.html#rightMarginChanged">rightMarginChanged</a></b></span>(int <i>rightMargin</i>)</td></tr>
</table></div>
<!-- @@@rightMargin -->
<!-- $$$target-prop$$$target -->
<h3 class="fn" id="target-prop"><a name="target-prop"></a><span class="name">target</span> : <span class="type"><a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a></span>* const</h3>
<p>绑定了锚定功能的控件对象</p>
<p><b>Note: </b>只读</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QWidget *</td><td class="memItemRight bottomAlign"><span class="name"><b>target</b></span>() const</td></tr>
</table></div>
<!-- @@@target -->
<!-- $$$topMargin-prop$$$topMargin$$$setTopMarginint$$$topMarginChangedint -->
<h3 class="fn" id="topMargin-prop"><a name="topMargin-prop"></a><span class="name">topMargin</span> : <span class="type">int</span></h3>
<p>上“锚线”的边距,优先级高于 margins</p>
<p><b>Note: </b>可读可写</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>topMargin</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setTopMargin</b></span>(int <i>topMargin</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="dtk-widget-danchorsbase.html#topMarginChanged">topMarginChanged</a></b></span>(int <i>topMargin</i>)</td></tr>
</table></div>
<!-- @@@topMargin -->
<!-- $$$verticalCenterOffset-prop$$$verticalCenterOffset$$$setVerticalCenterOffsetint$$$verticalCenterOffsetChangedint -->
<h3 class="fn" id="verticalCenterOffset-prop"><a name="verticalCenterOffset-prop"></a><span class="name">verticalCenterOffset</span> : <span class="type">int</span></h3>
<p>竖直“锚线”的偏移量</p>
<p><b>Note: </b>可读可写</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>verticalCenterOffset</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setVerticalCenterOffset</b></span>(int <i>verticalCenterOffset</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="dtk-widget-danchorsbase.html#verticalCenterOffsetChanged">verticalCenterOffsetChanged</a></b></span>(int <i>verticalCenterOffset</i>)</td></tr>
</table></div>
<!-- @@@verticalCenterOffset -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$DAnchorsBase[overload1]$$$DAnchorsBaseQWidget* -->
<h3 class="fn" id="DAnchorsBase"><a name="DAnchorsBase"></a>DAnchorsBase::<span class="name">DAnchorsBase</span>(<span class="type"><a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a></span> *<i>w</i>)</h3>
<p>构造 DAnchorsBase 对象,传入的 w 对象会和一个新的 DAnchorsBase 对象 绑定到一起 <i>w</i> 需要使用锚定关系的控件</p>
<p><b>Note: </b>对 w 设置的锚定关系不会随着本次构造的 DAnchorsBase 对象的销毁而消失。 此构造函数可能会隐式的构造一个新 DAnchorsBase 对象用于真正的功能实现,函数执行 时会先检查当前是否已经有和 w 对象绑定的 DAnchorsBase 对象,如果没有则会创建一 个新的 DAnchorsBase 对象与之绑定,否则使用已有的对象。隐式创建的 DAnchorsBase 对象会在对应的 <a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a> 对象被销毁时自动销毁。</p>
<p><b>See also </b><a href="dtk-widget-danchorsbase.html#target-prop">target</a>(), <a href="dtk-widget-danchorsbase.html#clearAnchors">clearAnchors</a>(), and <a href="dtk-widget-danchorsbase.html#getAnchorBaseByWidget">getAnchorBaseByWidget</a>().</p>
<!-- @@@DAnchorsBase -->
<!-- $$$bottomChanged[overload1]$$$bottomChangedconstDtk::Widget::DAnchorInfo* -->
<h3 class="fn" id="bottomChanged"><a name="bottomChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">bottomChanged</span>(const <span class="type"><a href="dtk-widget-danchorinfo.html">Dtk::Widget::DAnchorInfo</a></span> *<i>bottom</i>)</h3>
<p>信号会在 <i>bottom</i> 属性的值改变时被发送</p>
<!-- @@@bottomChanged -->
<!-- $$$bottomMarginChanged -->
<h3 class="fn" id="bottomMarginChanged"><a name="bottomMarginChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">bottomMarginChanged</span>(<span class="type">int</span> <i>bottomMargin</i>)</h3>
<p>信号会在 <i>bottomMargin</i> 属性的值改变时被发送</p>
<p><b>Note: </b>Notifier signal for property <a href="dtk-widget-danchorsbase.html#bottomMargin-prop">bottomMargin</a>. </p>
<!-- @@@bottomMarginChanged -->
<!-- $$$centerInChanged -->
<h3 class="fn" id="centerInChanged"><a name="centerInChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">centerInChanged</span>(<span class="type"><a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a></span> *<i>centerIn</i>)</h3>
<p>信号会在 <i>centerIn</i> 属性的值改变时被发送</p>
<p><b>Note: </b>Notifier signal for property <a href="dtk-widget-danchorsbase.html#centerIn-prop">centerIn</a>. </p>
<!-- @@@centerInChanged -->
<!-- $$$enabledChanged -->
<h3 class="fn" id="enabledChanged"><a name="enabledChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">enabledChanged</span>(<span class="type">bool</span> <i>enabled</i>)</h3>
<p>信号会在 <i>enabled</i> 属性的值改变时被发送</p>
<p><b>Note: </b>Notifier signal for property <a href="dtk-widget-danchorsbase.html#enabled-prop">enabled</a>. </p>
<!-- @@@enabledChanged -->
<!-- $$$fillChanged -->
<h3 class="fn" id="fillChanged"><a name="fillChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">fillChanged</span>(<span class="type"><a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a></span> *<i>fill</i>)</h3>
<p>信号会在 <i>fill</i> 属性的值改变时被发送</p>
<p><b>Note: </b>Notifier signal for property <a href="dtk-widget-danchorsbase.html#fill-prop">fill</a>. </p>
<!-- @@@fillChanged -->
<!-- $$$horizontalCenterChanged[overload1]$$$horizontalCenterChangedconstDtk::Widget::DAnchorInfo* -->
<h3 class="fn" id="horizontalCenterChanged"><a name="horizontalCenterChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">horizontalCenterChanged</span>(const <span class="type"><a href="dtk-widget-danchorinfo.html">Dtk::Widget::DAnchorInfo</a></span> *<i>horizontalCenter</i>)</h3>
<p>信号会在 <i>horizontalCenter</i> 属性的值改变时被发送</p>
<!-- @@@horizontalCenterChanged -->
<!-- $$$horizontalCenterOffsetChanged -->
<h3 class="fn" id="horizontalCenterOffsetChanged"><a name="horizontalCenterOffsetChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">horizontalCenterOffsetChanged</span>(<span class="type">int</span> <i>horizontalCenterOffset</i>)</h3>
<p>信号会在 <i>horizontalCenterOffset</i> 属性的值改变时被发送</p>
<p><b>Note: </b>Notifier signal for property <a href="dtk-widget-danchorsbase.html#horizontalCenterOffset-prop">horizontalCenterOffset</a>. </p>
<!-- @@@horizontalCenterOffsetChanged -->
<!-- $$$leftChanged[overload1]$$$leftChangedconstDtk::Widget::DAnchorInfo* -->
<h3 class="fn" id="leftChanged"><a name="leftChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">leftChanged</span>(const <span class="type"><a href="dtk-widget-danchorinfo.html">Dtk::Widget::DAnchorInfo</a></span> *<i>left</i>)</h3>
<p>信号会在 <i>left</i> 属性的值改变时被发送</p>
<!-- @@@leftChanged -->
<!-- $$$leftMarginChanged -->
<h3 class="fn" id="leftMarginChanged"><a name="leftMarginChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">leftMarginChanged</span>(<span class="type">int</span> <i>leftMargin</i>)</h3>
<p>信号会在 <i>leftMargin</i> 属性的值改变时被发送</p>
<p><b>Note: </b>Notifier signal for property <a href="dtk-widget-danchorsbase.html#leftMargin-prop">leftMargin</a>. </p>
<!-- @@@leftMarginChanged -->
<!-- $$$marginsChanged -->
<h3 class="fn" id="marginsChanged"><a name="marginsChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">marginsChanged</span>(<span class="type">int</span> <i>margins</i>)</h3>
<p>信号会在 <i>margins</i> 属性的值改变时被发送</p>
<p><b>Note: </b>Notifier signal for property <a href="dtk-widget-danchorsbase.html#margins-prop">margins</a>. </p>
<!-- @@@marginsChanged -->
<!-- $$$moveBottom[overload1]$$$moveBottomint -->
<h3 class="fn" id="moveBottom"><a name="moveBottom"></a><code>[slot] </code><span class="type">void</span> DAnchorsBase::<span class="name">moveBottom</span>(<span class="type">int</span> <i>arg</i>)</h3>
<p>移动 target 控件的下边界到 arg 这个位置 <i>arg</i> 要移动到的位置</p>
<!-- @@@moveBottom -->
<!-- $$$moveCenter[overload1]$$$moveCenterconstQPoint& -->
<h3 class="fn" id="moveCenter"><a name="moveCenter"></a><code>[slot] </code><span class="type">void</span> DAnchorsBase::<span class="name">moveCenter</span>(const <span class="type"><a href="http://doc.qt.io/qt-5/qpoint.html">QPoint</a></span> &<i>arg</i>)</h3>
<p>移动 target 控件的上边界到 arg 这个位置 <i>arg</i> 要移动到的位置</p>
<!-- @@@moveCenter -->
<!-- $$$moveHorizontalCenter[overload1]$$$moveHorizontalCenterint -->
<h3 class="fn" id="moveHorizontalCenter"><a name="moveHorizontalCenter"></a><code>[slot] </code><span class="type">void</span> DAnchorsBase::<span class="name">moveHorizontalCenter</span>(<span class="type">int</span> <i>arg</i>)</h3>
<p>移动 target 控件的水平中线到 arg 这个位置 <i>arg</i> 要移动到的位置</p>
<!-- @@@moveHorizontalCenter -->
<!-- $$$moveLeft[overload1]$$$moveLeftint -->
<h3 class="fn" id="moveLeft"><a name="moveLeft"></a><code>[slot] </code><span class="type">void</span> DAnchorsBase::<span class="name">moveLeft</span>(<span class="type">int</span> <i>arg</i>)</h3>
<p>移动 target 控件的左边界到 arg 这个位置 <i>arg</i> 要移动到的位置</p>
<!-- @@@moveLeft -->
<!-- $$$moveRight[overload1]$$$moveRightint -->
<h3 class="fn" id="moveRight"><a name="moveRight"></a><code>[slot] </code><span class="type">void</span> DAnchorsBase::<span class="name">moveRight</span>(<span class="type">int</span> <i>arg</i>)</h3>
<p>移动 target 控件的右边界到 arg 这个位置 <i>arg</i> 要移动到的位置</p>
<!-- @@@moveRight -->
<!-- $$$moveTop[overload1]$$$moveTopint -->
<h3 class="fn" id="moveTop"><a name="moveTop"></a><code>[slot] </code><span class="type">void</span> DAnchorsBase::<span class="name">moveTop</span>(<span class="type">int</span> <i>arg</i>)</h3>
<p>移动 target 控件的上边界到 arg 这个位置 <i>arg</i> 要移动到的位置</p>
<!-- @@@moveTop -->
<!-- $$$moveVerticalCenter[overload1]$$$moveVerticalCenterint -->
<h3 class="fn" id="moveVerticalCenter"><a name="moveVerticalCenter"></a><code>[slot] </code><span class="type">void</span> DAnchorsBase::<span class="name">moveVerticalCenter</span>(<span class="type">int</span> <i>arg</i>)</h3>
<p>移动 target 控件的竖直中线到 arg 这个位置 <i>arg</i> 要移动到的位置</p>
<!-- @@@moveVerticalCenter -->
<!-- $$$rightChanged[overload1]$$$rightChangedconstDtk::Widget::DAnchorInfo* -->
<h3 class="fn" id="rightChanged"><a name="rightChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">rightChanged</span>(const <span class="type"><a href="dtk-widget-danchorinfo.html">Dtk::Widget::DAnchorInfo</a></span> *<i>right</i>)</h3>
<p>信号会在 <i>right</i> 属性的值改变时被发送</p>
<!-- @@@rightChanged -->
<!-- $$$rightMarginChanged -->
<h3 class="fn" id="rightMarginChanged"><a name="rightMarginChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">rightMarginChanged</span>(<span class="type">int</span> <i>rightMargin</i>)</h3>
<p>信号会在 <i>rightMargin</i> 属性的值改变时被发送</p>
<p><b>Note: </b>Notifier signal for property <a href="dtk-widget-danchorsbase.html#rightMargin-prop">rightMargin</a>. </p>
<!-- @@@rightMarginChanged -->
<!-- $$$setCenterIn -->
<h3 class="fn" id="setCenterIn-1"><a name="setCenterIn-1"></a><code>[slot] </code><span class="type">bool</span> DAnchorsBase::<span class="name">setCenterIn</span>(<span class="type"><a href="dtk-widget-danchorsbase.html">Dtk::Widget::DAnchorsBase</a></span> *<i>centerIn</i>)</h3>
<p>将 <a href="dtk-widget-danchorsbase.html#centerIn-prop">centerIn</a> 中的<a href="dtk-widget-danchorsbase.html#target-prop">target</a>()作为参数调用其它重载函数 <i>centerIn</i> Returns</p>
<p><b>Note: </b>Setter function for property <a href="dtk-widget-danchorsbase.html#centerIn-prop">centerIn</a>. </p>
<!-- @@@setCenterIn -->
<!-- $$$setFill -->
<h3 class="fn" id="setFill-1"><a name="setFill-1"></a><code>[slot] </code><span class="type">bool</span> DAnchorsBase::<span class="name">setFill</span>(<span class="type"><a href="dtk-widget-danchorsbase.html">Dtk::Widget::DAnchorsBase</a></span> *<i>fill</i>)</h3>
<p>将 fill 中的<a href="dtk-widget-danchorsbase.html#target-prop">target</a>()作为参数调用其它重载函数 <i>fill</i> Returns</p>
<p><b>Note: </b>Setter function for property <a href="dtk-widget-danchorsbase.html#fill-prop">fill</a>. </p>
<!-- @@@setFill -->
<!-- $$$topChanged[overload1]$$$topChangedconstDtk::Widget::DAnchorInfo* -->
<h3 class="fn" id="topChanged"><a name="topChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">topChanged</span>(const <span class="type"><a href="dtk-widget-danchorinfo.html">Dtk::Widget::DAnchorInfo</a></span> *<i>top</i>)</h3>
<p>信号会在 <i>top</i> 属性的值改变时被发送</p>
<!-- @@@topChanged -->
<!-- $$$topMarginChanged -->
<h3 class="fn" id="topMarginChanged"><a name="topMarginChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">topMarginChanged</span>(<span class="type">int</span> <i>topMargin</i>)</h3>
<p>信号会在 <i>topMargin</i> 属性的值改变时被发送</p>
<p><b>Note: </b>Notifier signal for property <a href="dtk-widget-danchorsbase.html#topMargin-prop">topMargin</a>. </p>
<!-- @@@topMarginChanged -->
<!-- $$$verticalCenterChanged[overload1]$$$verticalCenterChangedconstDtk::Widget::DAnchorInfo* -->
<h3 class="fn" id="verticalCenterChanged"><a name="verticalCenterChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">verticalCenterChanged</span>(const <span class="type"><a href="dtk-widget-danchorinfo.html">Dtk::Widget::DAnchorInfo</a></span> *<i>verticalCenter</i>)</h3>
<p>信号会在 <i>verticalCenter</i> 属性的值改变时被发送</p>
<!-- @@@verticalCenterChanged -->
<!-- $$$verticalCenterOffsetChanged -->
<h3 class="fn" id="verticalCenterOffsetChanged"><a name="verticalCenterOffsetChanged"></a><code>[signal] </code><span class="type">void</span> DAnchorsBase::<span class="name">verticalCenterOffsetChanged</span>(<span class="type">int</span> <i>verticalCenterOffset</i>)</h3>
<p>信号会在 <i>verticalCenterOffset</i> 属性的值改变时被发送</p>
<p><b>Note: </b>Notifier signal for property <a href="dtk-widget-danchorsbase.html#verticalCenterOffset-prop">verticalCenterOffset</a>. </p>
<!-- @@@verticalCenterOffsetChanged -->
<!-- $$$~DAnchorsBase[overload1]$$$~DAnchorsBase -->
<h3 class="fn" id="dtor.DAnchorsBase"><a name="dtor.DAnchorsBase"></a>DAnchorsBase::<span class="name">~DAnchorsBase</span>()</h3>
<p>在析构时会判断此 <a href="dtk-widget-danchorsbase.html">DAnchorsBase</a> 对象是否和 target 存在绑定关系,如果是 则从映射表中移除绑定</p>
<p><b>Warning:</b> DAnchorsBasePrivate 对象可能是在多个 <a href="dtk-widget-danchorsbase.html">DAnchorsBase</a> 对象之间显式 共享的,所以在销毁 <a href="dtk-widget-danchorsbase.html">DAnchorsBase</a> 后,对应的 DAnchorsBasePrivate 对象不一定 会被销毁</p>
<p><b>See also </b><a href="http://doc.qt.io/qt-5/qexplicitlyshareddatapointer.html">QExplicitlySharedDataPointer</a>.</p>
<!-- @@@~DAnchorsBase -->
<!-- $$$clearAnchors[overload1]$$$clearAnchorsconstQWidget* -->
<h3 class="fn" id="clearAnchors"><a name="clearAnchors"></a><code>[static] </code><span class="type">void</span> DAnchorsBase::<span class="name">clearAnchors</span>(const <span class="type"><a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a></span> *<i>w</i>)</h3>
<p>清除和控件 w 相关的所有锚定关系,包括锚定w或者被w锚定的任何关联。会直接 销毁 w 对应的 <a href="dtk-widget-danchorsbase.html">DAnchorsBase</a> 对象 <i>w</i></p>
<!-- @@@clearAnchors -->
<!-- $$$enhancedWidget[overload1]$$$enhancedWidget -->
<h3 class="fn" id="enhancedWidget"><a name="enhancedWidget"></a><span class="type"><a href="dtk-widget-denhancedwidget.html">Dtk::Widget::DEnhancedWidget</a></span> *DAnchorsBase::<span class="name">enhancedWidget</span>() const</h3>
<p>返回 target 控件的扩展对象。此对象为 <a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a> 对象额外提供了和控件大小、 位置相关的变化信号 Returns</p>
<p><b>See also </b><a href="dtk-widget-denhancedwidget.html">Dtk::Widget::DEnhancedWidget</a>.</p>
<!-- @@@enhancedWidget -->
<!-- $$$errorCode[overload1]$$$errorCode -->
<h3 class="fn" id="errorCode"><a name="errorCode"></a><span class="type"><a href="dtk-widget-danchorsbase.html#AnchorError-enum">Dtk::Widget::DAnchorsBase::AnchorError</a></span> DAnchorsBase::<span class="name">errorCode</span>() const</h3>
<p>锚定过程中产生的错误,在一个新的锚定函数被调用之前会清空此错误状态,每次 调用锚定函数后,可以通过此函数的返回值来判断锚定设置是否成功 Returns</p>
<p><b>See also </b><a href="dtk-widget-danchorsbase.html#errorString">errorString</a>().</p>
<!-- @@@errorCode -->
<!-- $$$errorString[overload1]$$$errorString -->
<h3 class="fn" id="errorString"><a name="errorString"></a><span class="type"><a href="http://doc.qt.io/qt-5/qstring.html">QString</a></span> DAnchorsBase::<span class="name">errorString</span>() const</h3>
<p>对 <a href="dtk-widget-danchorsbase.html#errorCode">errorCode</a> 的文本描述信息 Returns</p>
<p><b>See also </b><a href="dtk-widget-danchorsbase.html#errorCode">errorCode</a>.</p>
<!-- @@@errorString -->
<!-- $$$getAnchorBaseByWidget[overload1]$$$getAnchorBaseByWidgetconstQWidget* -->
<h3 class="fn" id="getAnchorBaseByWidget"><a name="getAnchorBaseByWidget"></a><code>[static] </code><span class="type"><a href="dtk-widget-danchorsbase.html">Dtk::Widget::DAnchorsBase</a></span> *DAnchorsBase::<span class="name">getAnchorBaseByWidget</span>(const <span class="type"><a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a></span> *<i>w</i>)</h3>
<p>返回与 w 绑定的 <a href="dtk-widget-danchorsbase.html">DAnchorsBase</a> 对象 <i>w</i> Returns 如果 w 没有对应的锚定对象,则返回空</p>
<!-- @@@getAnchorBaseByWidget -->
<!-- $$$isBinding[overload1]$$$isBindingconstDtk::Widget::DAnchorInfo* -->
<h3 class="fn" id="isBinding"><a name="isBinding"></a><span class="type">bool</span> DAnchorsBase::<span class="name">isBinding</span>(const <span class="type"><a href="dtk-widget-danchorinfo.html">Dtk::Widget::DAnchorInfo</a></span> *<i>info</i>) const</h3>
<p>如果此 info 设置了锚定对象,则返回 true ,否则返回 false</p>
<pre class="cpp">
DAnchors<span class="operator"><</span><span class="type"><a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a></span><span class="operator">></span> w1;
DAnchors<span class="operator"><</span><span class="type"><a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a></span><span class="operator">></span> w2;
w1<span class="operator">.</span>setLeft(w2<span class="operator">.</span>right());
<a href="http://doc.qt.io/qt-5/qtglobal.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> w1<span class="operator">.</span>isBinding(w1<span class="operator">.</span>left()) <span class="operator"><</span><span class="operator"><</span> w2<span class="operator">.</span>isBinding(w2<span class="operator">.</span>right());
</pre>
<p>打印内容为:ture false <i>info</i> Returns</p>
<!-- @@@isBinding -->
</div>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2020 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.<br/> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br/> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>