回答編集履歴
13
修正
test
CHANGED
@@ -20,115 +20,129 @@
|
|
20
20
|
|
21
21
|
```Ruby
|
22
22
|
|
23
|
-
#encoding
|
23
|
+
# encoding: utf-8
|
24
24
|
|
25
|
+
|
26
|
+
|
25
|
-
require
|
27
|
+
require'qt'
|
26
28
|
|
27
29
|
|
28
30
|
|
29
31
|
class DesktopMascot < Qt::MainWindow
|
30
32
|
|
31
|
-
|
33
|
+
def initialize
|
32
34
|
|
33
|
-
|
35
|
+
super
|
34
36
|
|
35
|
-
|
37
|
+
# ウィンドウにセットするラベルの設定
|
36
38
|
|
37
|
-
|
39
|
+
label = Qt::Label.new
|
38
40
|
|
41
|
+
base = Qt::Image.new('character/000000/1.png')
|
42
|
+
|
43
|
+
# base = base.mirrored(true, false) => 画像の反転
|
44
|
+
|
45
|
+
# base = base.scaled(500, 500, Qt::KeepAspectRatio, Qt::SmoothTransformation) => リサイズ
|
46
|
+
|
47
|
+
pix = Qt::Pixmap::fromImage(base)
|
48
|
+
|
39
|
-
|
49
|
+
label.setPixmap(pix)
|
50
|
+
|
51
|
+
effect = Qt::GraphicsDropShadowEffect.new
|
52
|
+
|
53
|
+
effect.setColor(Qt::Color.new(0, 0, 0))
|
54
|
+
|
55
|
+
effect.setOffset(3, 3)
|
56
|
+
|
57
|
+
effect.setBlurRadius(20)
|
58
|
+
|
59
|
+
label.setGraphicsEffect(effect)
|
40
60
|
|
41
61
|
|
42
62
|
|
43
|
-
|
63
|
+
# ウィンドウの設定
|
44
64
|
|
45
|
-
|
65
|
+
setCentralWidget(label)
|
46
66
|
|
47
|
-
|
67
|
+
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint)
|
48
68
|
|
49
|
-
effect.setBlurRadius(20)
|
50
|
-
|
51
|
-
@label.setGraphicsEffect(effect)
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
setCentralWidget(@label)
|
56
|
-
|
57
|
-
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
|
58
|
-
|
59
|
-
|
69
|
+
setAttribute(Qt::WA_TranslucentBackground)
|
60
70
|
|
61
71
|
|
62
72
|
|
63
|
-
|
73
|
+
# マウスで移動させるための設定
|
64
74
|
|
75
|
+
@offset = Qt::Point.new
|
76
|
+
|
65
|
-
|
77
|
+
@left = false
|
66
78
|
|
67
79
|
|
68
80
|
|
81
|
+
# 各種アクション
|
82
|
+
|
69
|
-
|
83
|
+
createAction()
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
def mousePressEvent(event)
|
90
|
+
|
91
|
+
if event.button() && Qt::LeftButton
|
92
|
+
|
93
|
+
@offset = event.pos()
|
94
|
+
|
95
|
+
@left = true
|
70
96
|
|
71
97
|
end
|
72
98
|
|
99
|
+
end
|
73
100
|
|
101
|
+
|
74
102
|
|
75
|
-
|
103
|
+
def mouseMoveEvent(event)
|
76
104
|
|
77
|
-
|
105
|
+
if @left
|
78
106
|
|
79
|
-
|
107
|
+
move(mapToParent(event.pos() - @offset))
|
80
|
-
|
81
|
-
@left = true
|
82
|
-
|
83
|
-
end
|
84
108
|
|
85
109
|
end
|
86
110
|
|
111
|
+
end
|
87
112
|
|
113
|
+
|
88
114
|
|
89
|
-
|
115
|
+
def mouseReleaseEvent(event)
|
90
116
|
|
91
|
-
|
117
|
+
if event.button() && Qt::LeftButton
|
92
118
|
|
93
|
-
|
119
|
+
@left = false
|
94
|
-
|
95
|
-
end
|
96
120
|
|
97
121
|
end
|
98
122
|
|
99
|
-
|
100
|
-
|
101
|
-
def mouseReleaseEvent(event)
|
102
|
-
|
103
|
-
if event.button() == Qt::LeftButton
|
104
|
-
|
105
|
-
@left = false
|
106
|
-
|
107
|
-
|
123
|
+
end
|
108
|
-
|
109
|
-
end
|
110
124
|
|
111
125
|
|
112
126
|
|
113
|
-
|
127
|
+
def contextMenuEvent(event)
|
114
128
|
|
115
|
-
|
129
|
+
menu = Qt::Menu.new(self)
|
116
130
|
|
117
|
-
|
131
|
+
menu.addAction(@exitAct)
|
118
132
|
|
119
|
-
|
133
|
+
menu.exec(event.globalPos())
|
120
134
|
|
121
|
-
|
135
|
+
end
|
122
136
|
|
137
|
+
|
123
138
|
|
139
|
+
def createAction()
|
124
140
|
|
125
|
-
|
141
|
+
@exitAct = Qt::Action.new(tr('EXIT'), self)
|
126
142
|
|
127
|
-
|
143
|
+
connect(@exitAct, SIGNAL('triggered()'), self, SLOT('close()'))
|
128
144
|
|
129
|
-
connect(@exitAct, SIGNAL("triggered()"), self, SLOT("close()"))
|
130
|
-
|
131
|
-
|
145
|
+
end
|
132
146
|
|
133
147
|
end
|
134
148
|
|
12
修正
test
CHANGED
@@ -70,6 +70,8 @@
|
|
70
70
|
|
71
71
|
end
|
72
72
|
|
73
|
+
|
74
|
+
|
73
75
|
def mousePressEvent(event)
|
74
76
|
|
75
77
|
if event.button() == Qt::LeftButton
|
@@ -82,6 +84,8 @@
|
|
82
84
|
|
83
85
|
end
|
84
86
|
|
87
|
+
|
88
|
+
|
85
89
|
def mouseMoveEvent(event)
|
86
90
|
|
87
91
|
if @left == true
|
@@ -91,6 +95,8 @@
|
|
91
95
|
end
|
92
96
|
|
93
97
|
end
|
98
|
+
|
99
|
+
|
94
100
|
|
95
101
|
def mouseReleaseEvent(event)
|
96
102
|
|
@@ -102,6 +108,8 @@
|
|
102
108
|
|
103
109
|
end
|
104
110
|
|
111
|
+
|
112
|
+
|
105
113
|
def contextMenuEvent(event)
|
106
114
|
|
107
115
|
mainmenu = Qt::Menu.new(self)
|
@@ -111,6 +119,8 @@
|
|
111
119
|
mainmenu.exec(event.globalPos())
|
112
120
|
|
113
121
|
end
|
122
|
+
|
123
|
+
|
114
124
|
|
115
125
|
def createAction()
|
116
126
|
|
11
修正
test
CHANGED
@@ -20,163 +20,113 @@
|
|
20
20
|
|
21
21
|
```Ruby
|
22
22
|
|
23
|
-
#encoding: utf-8
|
23
|
+
#encoding : utf-8
|
24
24
|
|
25
25
|
require"qt"
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
-
class DesktopMascot < Qt::
|
29
|
+
class DesktopMascot < Qt::MainWindow
|
30
30
|
|
31
|
-
def initialize
|
31
|
+
def initialize
|
32
32
|
|
33
|
-
super
|
33
|
+
super
|
34
34
|
|
35
|
-
|
35
|
+
@label = Qt::Label.new
|
36
36
|
|
37
|
-
|
37
|
+
image = Qt::Pixmap.new("イメージ.png")
|
38
38
|
|
39
|
-
autoShadow()
|
40
|
-
|
41
|
-
|
39
|
+
@label.setPixmap(image)
|
42
40
|
|
43
41
|
|
44
42
|
|
45
|
-
|
43
|
+
effect = Qt::GraphicsDropShadowEffect.new
|
46
44
|
|
47
|
-
|
45
|
+
effect.setColor(Qt::Color.new(0, 0, 0))
|
48
46
|
|
47
|
+
effect.setOffset(1, 1)
|
48
|
+
|
49
|
+
effect.setBlurRadius(20)
|
50
|
+
|
51
|
+
@label.setGraphicsEffect(effect)
|
52
|
+
|
53
|
+
|
54
|
+
|
49
|
-
end
|
55
|
+
setCentralWidget(@label)
|
56
|
+
|
57
|
+
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
|
58
|
+
|
59
|
+
setAttribute(Qt::WA_TranslucentBackground)
|
50
60
|
|
51
61
|
|
52
62
|
|
53
|
-
|
63
|
+
@offset = Qt::Point.new
|
54
64
|
|
55
|
-
|
65
|
+
@left = false
|
56
|
-
|
57
|
-
setAttribute(Qt::WA_TranslucentBackground)
|
58
|
-
|
59
|
-
setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint)
|
60
|
-
|
61
|
-
end
|
62
66
|
|
63
67
|
|
64
68
|
|
65
|
-
def showImage()
|
66
|
-
|
67
|
-
@base = Qt::Image.new("イメージ.png")
|
68
|
-
|
69
|
-
@image = @base.mirrored(true, false)
|
70
|
-
|
71
|
-
pix = Qt::Pixmap::fromImage(@image)
|
72
|
-
|
73
|
-
resize(@image.width, @image.height)
|
74
|
-
|
75
|
-
setPixmap(pix)
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
69
|
+
createAction()
|
82
|
-
|
83
|
-
effect = Qt::GraphicsDropShadowEffect.new
|
84
|
-
|
85
|
-
effect.setColor(Qt::Color.new(0, 0, 0))
|
86
|
-
|
87
|
-
effect.setOffset(1, 1)
|
88
|
-
|
89
|
-
effect.setBlurRadius(10)
|
90
|
-
|
91
|
-
setGraphicsEffect(effect)
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
def mousePressEvent(event)
|
98
|
-
|
99
|
-
if event.button() == Qt::LeftButton
|
100
|
-
|
101
|
-
@offset = event.pos()
|
102
|
-
|
103
|
-
@left = true
|
104
70
|
|
105
71
|
end
|
106
72
|
|
107
|
-
en
|
73
|
+
def mousePressEvent(event)
|
108
74
|
|
75
|
+
if event.button() == Qt::LeftButton
|
109
76
|
|
77
|
+
@offset = event.pos()
|
110
78
|
|
111
|
-
|
79
|
+
@left = true
|
112
80
|
|
113
|
-
|
81
|
+
end
|
114
|
-
|
115
|
-
move(mapToParent(event.pos() - @offset))
|
116
82
|
|
117
83
|
end
|
118
84
|
|
119
|
-
en
|
85
|
+
def mouseMoveEvent(event)
|
120
86
|
|
87
|
+
if @left == true
|
121
88
|
|
89
|
+
move(mapToParent(event.pos() - @offset))
|
122
90
|
|
123
|
-
def mouseReleaseEvent(event)
|
124
|
-
|
125
|
-
if event.button() == Qt::LeftButton
|
126
|
-
|
127
|
-
|
91
|
+
end
|
128
92
|
|
129
93
|
end
|
130
94
|
|
131
|
-
en
|
95
|
+
def mouseReleaseEvent(event)
|
132
96
|
|
97
|
+
if event.button() == Qt::LeftButton
|
133
98
|
|
99
|
+
@left = false
|
134
100
|
|
135
|
-
|
101
|
+
end
|
136
102
|
|
137
|
-
|
103
|
+
end
|
138
104
|
|
139
|
-
|
105
|
+
def contextMenuEvent(event)
|
140
106
|
|
141
|
-
menu
|
107
|
+
mainmenu = Qt::Menu.new(self)
|
142
108
|
|
143
|
-
menu.
|
109
|
+
mainmenu.addAction(@exitAct)
|
144
110
|
|
145
|
-
en
|
111
|
+
mainmenu.exec(event.globalPos())
|
146
112
|
|
113
|
+
end
|
147
114
|
|
115
|
+
def createAction()
|
148
116
|
|
149
|
-
|
117
|
+
@exitAct = Qt::Action.new(tr("Exit"), self)
|
150
118
|
|
119
|
+
connect(@exitAct, SIGNAL("triggered()"), self, SLOT("close()"))
|
151
120
|
|
152
|
-
|
153
|
-
def flipImage()
|
154
|
-
|
155
|
-
#工事中
|
156
|
-
|
157
|
-
end
|
121
|
+
end
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
def createAction()
|
162
|
-
|
163
|
-
@exitAct = Qt::Action.new(tr("EXIT"), self)
|
164
|
-
|
165
|
-
connect(@exitAct, SIGNAL("triggered()"), self, SLOT("close()"))
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
@flipAct = Qt::Action.new(tr("Flip"), self)
|
170
|
-
|
171
|
-
connect(@flipAct, SIGNAL("triggered()"), SLOT("flipImage()"))
|
172
|
-
|
173
|
-
end
|
174
122
|
|
175
123
|
end
|
176
124
|
|
177
125
|
|
178
126
|
|
179
127
|
app = Qt::Application.new(ARGV)
|
128
|
+
|
129
|
+
|
180
130
|
|
181
131
|
mascot = DesktopMascot.new
|
182
132
|
|
10
修正
test
CHANGED
@@ -28,8 +28,6 @@
|
|
28
28
|
|
29
29
|
class DesktopMascot < Qt::Label
|
30
30
|
|
31
|
-
|
32
|
-
|
33
31
|
def initialize
|
34
32
|
|
35
33
|
super
|
@@ -68,7 +66,7 @@
|
|
68
66
|
|
69
67
|
@base = Qt::Image.new("イメージ.png")
|
70
68
|
|
71
|
-
@image = @base.mirrored(
|
69
|
+
@image = @base.mirrored(true, false)
|
72
70
|
|
73
71
|
pix = Qt::Pixmap::fromImage(@image)
|
74
72
|
|
9
修正
test
CHANGED
@@ -154,11 +154,11 @@
|
|
154
154
|
|
155
155
|
def flipImage()
|
156
156
|
|
157
|
-
|
157
|
+
#工事中
|
158
|
-
|
158
|
+
|
159
|
-
end
|
159
|
+
end
|
160
|
-
|
161
|
-
|
160
|
+
|
161
|
+
|
162
162
|
|
163
163
|
def createAction()
|
164
164
|
|
8
修正
test
CHANGED
@@ -28,37 +28,73 @@
|
|
28
28
|
|
29
29
|
class DesktopMascot < Qt::Label
|
30
30
|
|
31
|
+
|
32
|
+
|
31
33
|
def initialize
|
32
34
|
|
33
35
|
super
|
34
36
|
|
35
|
-
image = Qt::Pixmap.new("イメージ.png")
|
36
|
-
|
37
|
-
set
|
37
|
+
setWindow()
|
38
|
+
|
39
|
+
showImage()
|
40
|
+
|
41
|
+
autoShadow()
|
42
|
+
|
43
|
+
createAction()
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
@offset = Qt::Point.new
|
48
|
+
|
49
|
+
@left = false
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
def setWindow()
|
56
|
+
|
57
|
+
setScaledContents(true)
|
38
58
|
|
39
59
|
setAttribute(Qt::WA_TranslucentBackground)
|
40
60
|
|
41
61
|
setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint)
|
42
62
|
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
def showImage()
|
68
|
+
|
69
|
+
@base = Qt::Image.new("イメージ.png")
|
70
|
+
|
71
|
+
@image = @base.mirrored(@flip, false)
|
72
|
+
|
73
|
+
pix = Qt::Pixmap::fromImage(@image)
|
74
|
+
|
75
|
+
resize(@image.width, @image.height)
|
76
|
+
|
77
|
+
setPixmap(pix)
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
|
43
|
-
|
83
|
+
def autoShadow()
|
44
84
|
|
45
85
|
effect = Qt::GraphicsDropShadowEffect.new
|
46
86
|
|
47
|
-
effect.setColor(Qt::Color.new(0, 0, 0))
|
87
|
+
effect.setColor(Qt::Color.new(0, 0, 0))
|
48
|
-
|
88
|
+
|
49
|
-
effect.setOffset(
|
89
|
+
effect.setOffset(1, 1)
|
50
|
-
|
90
|
+
|
51
|
-
effect.setBlurRadius(
|
91
|
+
effect.setBlurRadius(10)
|
52
92
|
|
53
93
|
setGraphicsEffect(effect)
|
54
94
|
|
55
|
-
resize(image.width, image.height)
|
56
|
-
|
57
|
-
@offset = Qt::Point.new
|
58
|
-
|
59
|
-
@left = false
|
60
|
-
|
61
|
-
end
|
95
|
+
end
|
96
|
+
|
97
|
+
|
62
98
|
|
63
99
|
def mousePressEvent(event)
|
64
100
|
|
@@ -72,6 +108,8 @@
|
|
72
108
|
|
73
109
|
end
|
74
110
|
|
111
|
+
|
112
|
+
|
75
113
|
def mouseMoveEvent(event)
|
76
114
|
|
77
115
|
if @left == true
|
@@ -82,6 +120,8 @@
|
|
82
120
|
|
83
121
|
end
|
84
122
|
|
123
|
+
|
124
|
+
|
85
125
|
def mouseReleaseEvent(event)
|
86
126
|
|
87
127
|
if event.button() == Qt::LeftButton
|
@@ -92,15 +132,57 @@
|
|
92
132
|
|
93
133
|
end
|
94
134
|
|
135
|
+
|
136
|
+
|
137
|
+
def contextMenuEvent(event)
|
138
|
+
|
139
|
+
menu = Qt::Menu.new(self)
|
140
|
+
|
141
|
+
menu.addAction(@exitAct)
|
142
|
+
|
143
|
+
menu.addAction(@flipAct)
|
144
|
+
|
145
|
+
menu.exec(event.globalPos())
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
slots "flipImage()"
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
def flipImage()
|
156
|
+
|
157
|
+
puts "工事中"
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
def createAction()
|
164
|
+
|
165
|
+
@exitAct = Qt::Action.new(tr("EXIT"), self)
|
166
|
+
|
167
|
+
connect(@exitAct, SIGNAL("triggered()"), self, SLOT("close()"))
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
@flipAct = Qt::Action.new(tr("Flip"), self)
|
172
|
+
|
173
|
+
connect(@flipAct, SIGNAL("triggered()"), SLOT("flipImage()"))
|
174
|
+
|
175
|
+
end
|
176
|
+
|
95
177
|
end
|
96
178
|
|
97
179
|
|
98
180
|
|
99
181
|
app = Qt::Application.new(ARGV)
|
100
182
|
|
101
|
-
|
183
|
+
mascot = DesktopMascot.new
|
102
|
-
|
184
|
+
|
103
|
-
|
185
|
+
mascot.show
|
104
186
|
|
105
187
|
|
106
188
|
|
7
修正
test
CHANGED
@@ -78,8 +78,6 @@
|
|
78
78
|
|
79
79
|
move(mapToParent(event.pos() - @offset))
|
80
80
|
|
81
|
-
@lastpoint = event.pos()
|
82
|
-
|
83
81
|
end
|
84
82
|
|
85
83
|
end
|
6
修正
test
CHANGED
@@ -122,9 +122,13 @@
|
|
122
122
|
|
123
123
|
|
124
124
|
|
125
|
+
|
126
|
+
|
125
127
|
参考
|
126
128
|
|
127
129
|
[Qtでデスクトップマスコット的なのを実現する方法](http://amagitakayosi.hatenablog.com/entry/20121212/qt_mas)
|
130
|
+
|
131
|
+
[QT4 Drag Window Without Title Bar](http://stackoverflow.com/questions/1361132/qt4-drag-window-without-title-bar)
|
128
132
|
|
129
133
|
[Moving object with mouse](http://stackoverflow.com/questions/11172420/moving-object-with-mouse)
|
130
134
|
|
5
修正
test
CHANGED
@@ -35,8 +35,6 @@
|
|
35
35
|
image = Qt::Pixmap.new("イメージ.png")
|
36
36
|
|
37
37
|
setPixmap(image)
|
38
|
-
|
39
|
-
setStyleSheet("background:transparent; border: none;")
|
40
38
|
|
41
39
|
setAttribute(Qt::WA_TranslucentBackground)
|
42
40
|
|
@@ -130,6 +128,8 @@
|
|
130
128
|
|
131
129
|
[Moving object with mouse](http://stackoverflow.com/questions/11172420/moving-object-with-mouse)
|
132
130
|
|
131
|
+
[widget透過のまとめ](http://folioscope.hatenablog.jp/entry/20110104/1294157371)
|
133
132
|
|
134
133
|
|
135
134
|
|
135
|
+
|
4
修正
test
CHANGED
@@ -36,17 +36,25 @@
|
|
36
36
|
|
37
37
|
setPixmap(image)
|
38
38
|
|
39
|
-
resize(image.width, image.height)
|
40
|
-
|
41
39
|
setStyleSheet("background:transparent; border: none;")
|
42
40
|
|
43
41
|
setAttribute(Qt::WA_TranslucentBackground)
|
44
42
|
|
45
|
-
setWindowFlags(Qt::FramelessWindowHint)
|
46
|
-
|
47
43
|
setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint)
|
48
44
|
|
49
45
|
setScaledContents(true)
|
46
|
+
|
47
|
+
effect = Qt::GraphicsDropShadowEffect.new
|
48
|
+
|
49
|
+
effect.setColor(Qt::Color.new(0, 0, 0)) #影の色
|
50
|
+
|
51
|
+
effect.setOffset(5, 5) #影の大きさ
|
52
|
+
|
53
|
+
effect.setBlurRadius(20) #影のぼやけ具合
|
54
|
+
|
55
|
+
setGraphicsEffect(effect)
|
56
|
+
|
57
|
+
resize(image.width, image.height)
|
50
58
|
|
51
59
|
@offset = Qt::Point.new
|
52
60
|
|
@@ -113,3 +121,15 @@
|
|
113
121
|
上のコードで、非矩形ウィンドウの作成とタイトルバーがない状態での
|
114
122
|
|
115
123
|
ドラッグ移動ができるようになっています。
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
参考
|
128
|
+
|
129
|
+
[Qtでデスクトップマスコット的なのを実現する方法](http://amagitakayosi.hatenablog.com/entry/20121212/qt_mas)
|
130
|
+
|
131
|
+
[Moving object with mouse](http://stackoverflow.com/questions/11172420/moving-object-with-mouse)
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
3
修正
test
CHANGED
@@ -106,7 +106,7 @@
|
|
106
106
|
|
107
107
|
qtbindingsというgemを利用します。
|
108
108
|
|
109
|
-
これなら
|
109
|
+
これならocraでexe化できます。(ただし、とても時間がかかる。)
|
110
110
|
|
111
111
|
起動にも時間がかかるので、Rubyにこだわらなければ他の言語で作った方がよさげです。
|
112
112
|
|
2
修正
test
CHANGED
@@ -108,7 +108,7 @@
|
|
108
108
|
|
109
109
|
これならOCRAでexe化できます。(ただし、とても時間がかかる。)
|
110
110
|
|
111
|
-
起動にも時間がかかるので、Rubyにこだわらなければ
|
111
|
+
起動にも時間がかかるので、Rubyにこだわらなければ他の言語で作った方がよさげです。
|
112
112
|
|
113
113
|
上のコードで、非矩形ウィンドウの作成とタイトルバーがない状態での
|
114
114
|
|
1
修正
test
CHANGED
@@ -13,3 +13,103 @@
|
|
13
13
|
|
14
14
|
|
15
15
|
これからC#の勉強をしようと思います。
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
#追記
|
20
|
+
|
21
|
+
```Ruby
|
22
|
+
|
23
|
+
#encoding: utf-8
|
24
|
+
|
25
|
+
require"qt"
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
class DesktopMascot < Qt::Label
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
|
33
|
+
super
|
34
|
+
|
35
|
+
image = Qt::Pixmap.new("イメージ.png")
|
36
|
+
|
37
|
+
setPixmap(image)
|
38
|
+
|
39
|
+
resize(image.width, image.height)
|
40
|
+
|
41
|
+
setStyleSheet("background:transparent; border: none;")
|
42
|
+
|
43
|
+
setAttribute(Qt::WA_TranslucentBackground)
|
44
|
+
|
45
|
+
setWindowFlags(Qt::FramelessWindowHint)
|
46
|
+
|
47
|
+
setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint)
|
48
|
+
|
49
|
+
setScaledContents(true)
|
50
|
+
|
51
|
+
@offset = Qt::Point.new
|
52
|
+
|
53
|
+
@left = false
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
def mousePressEvent(event)
|
58
|
+
|
59
|
+
if event.button() == Qt::LeftButton
|
60
|
+
|
61
|
+
@offset = event.pos()
|
62
|
+
|
63
|
+
@left = true
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
def mouseMoveEvent(event)
|
70
|
+
|
71
|
+
if @left == true
|
72
|
+
|
73
|
+
move(mapToParent(event.pos() - @offset))
|
74
|
+
|
75
|
+
@lastpoint = event.pos()
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
def mouseReleaseEvent(event)
|
82
|
+
|
83
|
+
if event.button() == Qt::LeftButton
|
84
|
+
|
85
|
+
@left = false
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
app = Qt::Application.new(ARGV)
|
96
|
+
|
97
|
+
window = DesktopMascot.new
|
98
|
+
|
99
|
+
window.show
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
app.exec
|
104
|
+
|
105
|
+
```
|
106
|
+
|
107
|
+
qtbindingsというgemを利用します。
|
108
|
+
|
109
|
+
これならOCRAでexe化できます。(ただし、とても時間がかかる。)
|
110
|
+
|
111
|
+
起動にも時間がかかるので、RubyにこだわらなければC#で作った方がよさげです。
|
112
|
+
|
113
|
+
上のコードで、非矩形ウィンドウの作成とタイトルバーがない状態での
|
114
|
+
|
115
|
+
ドラッグ移動ができるようになっています。
|