回答編集履歴

4

誤字修正

2017/09/09 10:11

投稿

LouiS0616
LouiS0616

スコア35658

test CHANGED
@@ -72,7 +72,7 @@
72
72
 
73
73
  - **多重継承を出来るだけ避ける**
74
74
 
75
- これはQtの注意点というより、C++の注意点ですね。最新の注意が必要となります。
75
+ これはQtの注意点というより、C++の注意点ですね。細心の注意が必要となります。
76
76
 
77
77
  - **困ったらリビルド**
78
78
 
@@ -88,7 +88,7 @@
88
88
 
89
89
  ### 適当に組んでみた
90
90
 
91
- Swingを割と意識してますが、こっちもうろ覚えだったりします。
91
+ SwingやAWTを割と意識してますが、こっちもうろ覚えだったりします。
92
92
 
93
93
  ```C++
94
94
 

3

追記

2017/09/09 10:11

投稿

LouiS0616
LouiS0616

スコア35658

test CHANGED
@@ -44,7 +44,11 @@
44
44
 
45
45
  - **QObjectを継承したクラスの定義部先頭に、Q_OBJECTマクロを書く**
46
46
 
47
- 必須です。これがないと、おそらくsignal/slotの恩恵に預かれません。
47
+ 必須です。これがないと、signal/slotの恩恵に預かれません。
48
+
49
+ > Notice that **the Q_OBJECT macro is mandatory** for any object that implements signals, slots or properties. [引用元](http://doc.qt.io/qt-5/qobject.html#details)
50
+
51
+
48
52
 
49
53
  - **クラスの定義と実装を分ける**
50
54
 
@@ -62,6 +66,10 @@
62
66
 
63
67
  Qt系のクラスは、メモリリークを防ぐ仕組みを持っているらしいです。
64
68
 
69
+ > When QObjects are created on the heap (i.e., created with new), a tree can be constructed from them in any order, and later, the objects in the tree can be destroyed in any order. When any QObject in the tree is deleted, if the object has a parent, the destructor automatically removes the object from its parent. If the object has children, **the destructor automatically deletes each child**. No QObject is deleted twice, regardless of the order of destruction. [引用元](http://doc.qt.io/qt-5/objecttrees.html#construction-destruction-order-of-qobjects)
70
+
71
+
72
+
65
73
  - **多重継承を出来るだけ避ける**
66
74
 
67
75
  これはQtの注意点というより、C++の注意点ですね。最新の注意が必要となります。
@@ -315,3 +323,7 @@
315
323
  sw_like::JDialogを作らなかったのは手抜きです。すみません。
316
324
 
317
325
  (だいたい)仕様通りに動作しますが、参考程度にお願いします。
326
+
327
+
328
+
329
+ ...メモリリークが本当に起きていないかは、ちょっと自信がありません。

2

追記

2017/09/09 09:44

投稿

LouiS0616
LouiS0616

スコア35658

test CHANGED
@@ -50,6 +50,10 @@
50
50
 
51
51
  確かQtのバグか何かで、Q_OBJECTマクロと一部の実装を分けないと正常動作しません。
52
52
 
53
+ - **クラス間のやり取りはsignal/slot**
54
+
55
+ マルチスレッド化するときに便利です。それに、メッセージパッシングってよさげ。
56
+
53
57
  - **出来るだけQtに予め用意されているクラスを用いる**
54
58
 
55
59
  出力はqDebug、文字列はQString。他にもあるかもしれません。

1

OS書いてなかった

2017/09/09 09:20

投稿

LouiS0616
LouiS0616

スコア35658

test CHANGED
@@ -1,6 +1,6 @@
1
1
  ### とりあえずエラーを消す
2
2
 
3
- Visual Studio 2015 + Qt5.6.0 で試してみました。
3
+ Windows10 + Visual Studio 2015 + Qt5.6.0 で試してみました。
4
4
 
5
5
  質問者様のプログラムを実行すると、次のようなログが出力されました。
6
6