回答編集履歴
13
修正
answer
CHANGED
@@ -9,61 +9,68 @@
|
|
9
9
|
|
10
10
|
#追記
|
11
11
|
```Ruby
|
12
|
-
#
|
12
|
+
# encoding: utf-8
|
13
|
-
require"qt"
|
14
13
|
|
14
|
+
require'qt'
|
15
|
+
|
15
16
|
class DesktopMascot < Qt::MainWindow
|
16
|
-
|
17
|
+
def initialize
|
17
|
-
|
18
|
+
super
|
19
|
+
# ウィンドウにセットするラベルの設定
|
18
|
-
|
20
|
+
label = Qt::Label.new
|
21
|
+
base = Qt::Image.new('character/000000/1.png')
|
22
|
+
# base = base.mirrored(true, false) => 画像の反転
|
23
|
+
# base = base.scaled(500, 500, Qt::KeepAspectRatio, Qt::SmoothTransformation) => リサイズ
|
19
|
-
|
24
|
+
pix = Qt::Pixmap::fromImage(base)
|
20
|
-
|
25
|
+
label.setPixmap(pix)
|
26
|
+
effect = Qt::GraphicsDropShadowEffect.new
|
27
|
+
effect.setColor(Qt::Color.new(0, 0, 0))
|
28
|
+
effect.setOffset(3, 3)
|
29
|
+
effect.setBlurRadius(20)
|
30
|
+
label.setGraphicsEffect(effect)
|
21
31
|
|
22
|
-
effect = Qt::GraphicsDropShadowEffect.new
|
23
|
-
effect.setColor(Qt::Color.new(0, 0, 0))
|
24
|
-
|
32
|
+
# ウィンドウの設定
|
25
|
-
effect.setBlurRadius(20)
|
26
|
-
@label.setGraphicsEffect(effect)
|
27
|
-
|
28
|
-
|
33
|
+
setCentralWidget(label)
|
29
|
-
|
34
|
+
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint)
|
30
|
-
|
35
|
+
setAttribute(Qt::WA_TranslucentBackground)
|
31
36
|
|
37
|
+
# マウスで移動させるための設定
|
32
|
-
|
38
|
+
@offset = Qt::Point.new
|
33
|
-
|
39
|
+
@left = false
|
34
40
|
|
41
|
+
# 各種アクション
|
35
|
-
|
42
|
+
createAction()
|
36
|
-
|
43
|
+
end
|
37
44
|
|
38
|
-
|
45
|
+
def mousePressEvent(event)
|
39
|
-
|
46
|
+
if event.button() && Qt::LeftButton
|
40
|
-
|
47
|
+
@offset = event.pos()
|
41
|
-
|
48
|
+
@left = true
|
42
|
-
end
|
43
49
|
end
|
44
|
-
|
50
|
+
end
|
51
|
+
|
45
|
-
|
52
|
+
def mouseMoveEvent(event)
|
46
|
-
|
53
|
+
if @left
|
47
|
-
|
54
|
+
move(mapToParent(event.pos() - @offset))
|
48
|
-
end
|
49
55
|
end
|
50
|
-
|
56
|
+
end
|
57
|
+
|
51
|
-
|
58
|
+
def mouseReleaseEvent(event)
|
52
|
-
|
59
|
+
if event.button() && Qt::LeftButton
|
53
|
-
|
60
|
+
@left = false
|
54
|
-
end
|
55
61
|
end
|
62
|
+
end
|
56
63
|
|
57
|
-
|
64
|
+
def contextMenuEvent(event)
|
58
|
-
|
65
|
+
menu = Qt::Menu.new(self)
|
59
|
-
|
66
|
+
menu.addAction(@exitAct)
|
60
|
-
|
67
|
+
menu.exec(event.globalPos())
|
61
|
-
|
68
|
+
end
|
62
|
-
|
69
|
+
|
63
|
-
|
70
|
+
def createAction()
|
64
|
-
|
71
|
+
@exitAct = Qt::Action.new(tr('EXIT'), self)
|
65
|
-
|
72
|
+
connect(@exitAct, SIGNAL('triggered()'), self, SLOT('close()'))
|
66
|
-
|
73
|
+
end
|
67
74
|
end
|
68
75
|
|
69
76
|
app = Qt::Application.new(ARGV)
|
12
修正
answer
CHANGED
@@ -34,27 +34,32 @@
|
|
34
34
|
|
35
35
|
createAction()
|
36
36
|
end
|
37
|
+
|
37
38
|
def mousePressEvent(event)
|
38
39
|
if event.button() == Qt::LeftButton
|
39
40
|
@offset = event.pos()
|
40
41
|
@left = true
|
41
42
|
end
|
42
43
|
end
|
44
|
+
|
43
45
|
def mouseMoveEvent(event)
|
44
46
|
if @left == true
|
45
47
|
move(mapToParent(event.pos() - @offset))
|
46
48
|
end
|
47
49
|
end
|
50
|
+
|
48
51
|
def mouseReleaseEvent(event)
|
49
52
|
if event.button() == Qt::LeftButton
|
50
53
|
@left = false
|
51
54
|
end
|
52
55
|
end
|
56
|
+
|
53
57
|
def contextMenuEvent(event)
|
54
58
|
mainmenu = Qt::Menu.new(self)
|
55
59
|
mainmenu.addAction(@exitAct)
|
56
60
|
mainmenu.exec(event.globalPos())
|
57
61
|
end
|
62
|
+
|
58
63
|
def createAction()
|
59
64
|
@exitAct = Qt::Action.new(tr("Exit"), self)
|
60
65
|
connect(@exitAct, SIGNAL("triggered()"), self, SLOT("close()"))
|
11
修正
answer
CHANGED
@@ -9,85 +9,60 @@
|
|
9
9
|
|
10
10
|
#追記
|
11
11
|
```Ruby
|
12
|
-
#encoding: utf-8
|
12
|
+
#encoding : utf-8
|
13
13
|
require"qt"
|
14
14
|
|
15
|
-
class DesktopMascot < Qt::
|
15
|
+
class DesktopMascot < Qt::MainWindow
|
16
|
-
|
16
|
+
def initialize
|
17
|
-
|
17
|
+
super
|
18
|
-
setWindow()
|
19
|
-
showImage()
|
20
|
-
|
18
|
+
@label = Qt::Label.new
|
19
|
+
image = Qt::Pixmap.new("イメージ.png")
|
21
|
-
|
20
|
+
@label.setPixmap(image)
|
22
21
|
|
23
|
-
|
22
|
+
effect = Qt::GraphicsDropShadowEffect.new
|
23
|
+
effect.setColor(Qt::Color.new(0, 0, 0))
|
24
|
-
|
24
|
+
effect.setOffset(1, 1)
|
25
|
+
effect.setBlurRadius(20)
|
26
|
+
@label.setGraphicsEffect(effect)
|
27
|
+
|
25
|
-
|
28
|
+
setCentralWidget(@label)
|
29
|
+
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
|
30
|
+
setAttribute(Qt::WA_TranslucentBackground)
|
26
31
|
|
27
|
-
|
32
|
+
@offset = Qt::Point.new
|
28
|
-
|
33
|
+
@left = false
|
29
|
-
setAttribute(Qt::WA_TranslucentBackground)
|
30
|
-
setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint)
|
31
|
-
end
|
32
34
|
|
33
|
-
def showImage()
|
34
|
-
@base = Qt::Image.new("イメージ.png")
|
35
|
-
@image = @base.mirrored(true, false)
|
36
|
-
pix = Qt::Pixmap::fromImage(@image)
|
37
|
-
resize(@image.width, @image.height)
|
38
|
-
setPixmap(pix)
|
39
|
-
end
|
40
|
-
|
41
|
-
|
35
|
+
createAction()
|
42
|
-
effect = Qt::GraphicsDropShadowEffect.new
|
43
|
-
effect.setColor(Qt::Color.new(0, 0, 0))
|
44
|
-
effect.setOffset(1, 1)
|
45
|
-
effect.setBlurRadius(10)
|
46
|
-
setGraphicsEffect(effect)
|
47
|
-
end
|
48
|
-
|
49
|
-
def mousePressEvent(event)
|
50
|
-
if event.button() == Qt::LeftButton
|
51
|
-
@offset = event.pos()
|
52
|
-
@left = true
|
53
36
|
end
|
37
|
+
def mousePressEvent(event)
|
38
|
+
if event.button() == Qt::LeftButton
|
39
|
+
@offset = event.pos()
|
40
|
+
@left = true
|
54
|
-
|
41
|
+
end
|
55
|
-
|
56
|
-
def mouseMoveEvent(event)
|
57
|
-
if @left == true
|
58
|
-
move(mapToParent(event.pos() - @offset))
|
59
42
|
end
|
43
|
+
def mouseMoveEvent(event)
|
44
|
+
if @left == true
|
45
|
+
move(mapToParent(event.pos() - @offset))
|
60
|
-
|
46
|
+
end
|
61
|
-
|
62
|
-
def mouseReleaseEvent(event)
|
63
|
-
if event.button() == Qt::LeftButton
|
64
|
-
@left = false
|
65
47
|
end
|
48
|
+
def mouseReleaseEvent(event)
|
49
|
+
if event.button() == Qt::LeftButton
|
50
|
+
@left = false
|
66
|
-
|
51
|
+
end
|
67
|
-
|
52
|
+
end
|
68
|
-
|
53
|
+
def contextMenuEvent(event)
|
69
|
-
|
54
|
+
mainmenu = Qt::Menu.new(self)
|
70
|
-
|
55
|
+
mainmenu.addAction(@exitAct)
|
71
|
-
menu.addAction(@flipAct)
|
72
|
-
|
56
|
+
mainmenu.exec(event.globalPos())
|
73
|
-
|
57
|
+
end
|
74
|
-
|
75
|
-
slots "flipImage()"
|
76
|
-
|
77
|
-
|
58
|
+
def createAction()
|
78
|
-
|
59
|
+
@exitAct = Qt::Action.new(tr("Exit"), self)
|
60
|
+
connect(@exitAct, SIGNAL("triggered()"), self, SLOT("close()"))
|
79
|
-
|
61
|
+
end
|
80
|
-
|
81
|
-
def createAction()
|
82
|
-
@exitAct = Qt::Action.new(tr("EXIT"), self)
|
83
|
-
connect(@exitAct, SIGNAL("triggered()"), self, SLOT("close()"))
|
84
|
-
|
85
|
-
@flipAct = Qt::Action.new(tr("Flip"), self)
|
86
|
-
connect(@flipAct, SIGNAL("triggered()"), SLOT("flipImage()"))
|
87
|
-
end
|
88
62
|
end
|
89
63
|
|
90
64
|
app = Qt::Application.new(ARGV)
|
65
|
+
|
91
66
|
mascot = DesktopMascot.new
|
92
67
|
mascot.show
|
93
68
|
|
10
修正
answer
CHANGED
@@ -13,7 +13,6 @@
|
|
13
13
|
require"qt"
|
14
14
|
|
15
15
|
class DesktopMascot < Qt::Label
|
16
|
-
|
17
16
|
def initialize
|
18
17
|
super
|
19
18
|
setWindow()
|
@@ -33,7 +32,7 @@
|
|
33
32
|
|
34
33
|
def showImage()
|
35
34
|
@base = Qt::Image.new("イメージ.png")
|
36
|
-
@image = @base.mirrored(
|
35
|
+
@image = @base.mirrored(true, false)
|
37
36
|
pix = Qt::Pixmap::fromImage(@image)
|
38
37
|
resize(@image.width, @image.height)
|
39
38
|
setPixmap(pix)
|
9
修正
answer
CHANGED
@@ -76,9 +76,9 @@
|
|
76
76
|
slots "flipImage()"
|
77
77
|
|
78
78
|
def flipImage()
|
79
|
-
|
79
|
+
#工事中
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
def createAction()
|
83
83
|
@exitAct = Qt::Action.new(tr("EXIT"), self)
|
84
84
|
connect(@exitAct, SIGNAL("triggered()"), self, SLOT("close()"))
|
8
修正
answer
CHANGED
@@ -13,43 +13,84 @@
|
|
13
13
|
require"qt"
|
14
14
|
|
15
15
|
class DesktopMascot < Qt::Label
|
16
|
+
|
16
17
|
def initialize
|
17
18
|
super
|
18
|
-
image = Qt::Pixmap.new("イメージ.png")
|
19
|
-
|
19
|
+
setWindow()
|
20
|
+
showImage()
|
21
|
+
autoShadow()
|
22
|
+
createAction()
|
23
|
+
|
24
|
+
@offset = Qt::Point.new
|
25
|
+
@left = false
|
26
|
+
end
|
27
|
+
|
28
|
+
def setWindow()
|
29
|
+
setScaledContents(true)
|
20
30
|
setAttribute(Qt::WA_TranslucentBackground)
|
21
31
|
setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint)
|
32
|
+
end
|
33
|
+
|
34
|
+
def showImage()
|
35
|
+
@base = Qt::Image.new("イメージ.png")
|
36
|
+
@image = @base.mirrored(@flip, false)
|
37
|
+
pix = Qt::Pixmap::fromImage(@image)
|
38
|
+
resize(@image.width, @image.height)
|
39
|
+
setPixmap(pix)
|
40
|
+
end
|
41
|
+
|
22
|
-
|
42
|
+
def autoShadow()
|
23
43
|
effect = Qt::GraphicsDropShadowEffect.new
|
24
|
-
effect.setColor(Qt::Color.new(0, 0, 0))
|
44
|
+
effect.setColor(Qt::Color.new(0, 0, 0))
|
25
|
-
effect.setOffset(
|
45
|
+
effect.setOffset(1, 1)
|
26
|
-
effect.setBlurRadius(
|
46
|
+
effect.setBlurRadius(10)
|
27
47
|
setGraphicsEffect(effect)
|
28
|
-
resize(image.width, image.height)
|
29
|
-
@offset = Qt::Point.new
|
30
|
-
@left = false
|
31
48
|
end
|
49
|
+
|
32
50
|
def mousePressEvent(event)
|
33
51
|
if event.button() == Qt::LeftButton
|
34
52
|
@offset = event.pos()
|
35
53
|
@left = true
|
36
54
|
end
|
37
55
|
end
|
56
|
+
|
38
57
|
def mouseMoveEvent(event)
|
39
58
|
if @left == true
|
40
59
|
move(mapToParent(event.pos() - @offset))
|
41
60
|
end
|
42
61
|
end
|
62
|
+
|
43
63
|
def mouseReleaseEvent(event)
|
44
64
|
if event.button() == Qt::LeftButton
|
45
65
|
@left = false
|
46
66
|
end
|
47
67
|
end
|
68
|
+
|
69
|
+
def contextMenuEvent(event)
|
70
|
+
menu = Qt::Menu.new(self)
|
71
|
+
menu.addAction(@exitAct)
|
72
|
+
menu.addAction(@flipAct)
|
73
|
+
menu.exec(event.globalPos())
|
74
|
+
end
|
75
|
+
|
76
|
+
slots "flipImage()"
|
77
|
+
|
78
|
+
def flipImage()
|
79
|
+
puts "工事中"
|
80
|
+
end
|
81
|
+
|
82
|
+
def createAction()
|
83
|
+
@exitAct = Qt::Action.new(tr("EXIT"), self)
|
84
|
+
connect(@exitAct, SIGNAL("triggered()"), self, SLOT("close()"))
|
85
|
+
|
86
|
+
@flipAct = Qt::Action.new(tr("Flip"), self)
|
87
|
+
connect(@flipAct, SIGNAL("triggered()"), SLOT("flipImage()"))
|
88
|
+
end
|
48
89
|
end
|
49
90
|
|
50
91
|
app = Qt::Application.new(ARGV)
|
51
|
-
|
92
|
+
mascot = DesktopMascot.new
|
52
|
-
|
93
|
+
mascot.show
|
53
94
|
|
54
95
|
app.exec
|
55
96
|
```
|
7
修正
answer
CHANGED
@@ -38,7 +38,6 @@
|
|
38
38
|
def mouseMoveEvent(event)
|
39
39
|
if @left == true
|
40
40
|
move(mapToParent(event.pos() - @offset))
|
41
|
-
@lastpoint = event.pos()
|
42
41
|
end
|
43
42
|
end
|
44
43
|
def mouseReleaseEvent(event)
|
6
修正
answer
CHANGED
@@ -60,8 +60,10 @@
|
|
60
60
|
上のコードで、非矩形ウィンドウの作成とタイトルバーがない状態での
|
61
61
|
ドラッグ移動ができるようになっています。
|
62
62
|
|
63
|
+
|
63
64
|
参考
|
64
65
|
[Qtでデスクトップマスコット的なのを実現する方法](http://amagitakayosi.hatenablog.com/entry/20121212/qt_mas)
|
66
|
+
[QT4 Drag Window Without Title Bar](http://stackoverflow.com/questions/1361132/qt4-drag-window-without-title-bar)
|
65
67
|
[Moving object with mouse](http://stackoverflow.com/questions/11172420/moving-object-with-mouse)
|
66
68
|
[widget透過のまとめ](http://folioscope.hatenablog.jp/entry/20110104/1294157371)
|
67
69
|
|
5
修正
answer
CHANGED
@@ -17,7 +17,6 @@
|
|
17
17
|
super
|
18
18
|
image = Qt::Pixmap.new("イメージ.png")
|
19
19
|
setPixmap(image)
|
20
|
-
setStyleSheet("background:transparent; border: none;")
|
21
20
|
setAttribute(Qt::WA_TranslucentBackground)
|
22
21
|
setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint)
|
23
22
|
setScaledContents(true)
|
@@ -64,4 +63,5 @@
|
|
64
63
|
参考
|
65
64
|
[Qtでデスクトップマスコット的なのを実現する方法](http://amagitakayosi.hatenablog.com/entry/20121212/qt_mas)
|
66
65
|
[Moving object with mouse](http://stackoverflow.com/questions/11172420/moving-object-with-mouse)
|
66
|
+
[widget透過のまとめ](http://folioscope.hatenablog.jp/entry/20110104/1294157371)
|
67
67
|
|
4
修正
answer
CHANGED
@@ -17,12 +17,16 @@
|
|
17
17
|
super
|
18
18
|
image = Qt::Pixmap.new("イメージ.png")
|
19
19
|
setPixmap(image)
|
20
|
-
resize(image.width, image.height)
|
21
20
|
setStyleSheet("background:transparent; border: none;")
|
22
21
|
setAttribute(Qt::WA_TranslucentBackground)
|
23
|
-
setWindowFlags(Qt::FramelessWindowHint)
|
24
22
|
setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint)
|
25
23
|
setScaledContents(true)
|
24
|
+
effect = Qt::GraphicsDropShadowEffect.new
|
25
|
+
effect.setColor(Qt::Color.new(0, 0, 0)) #影の色
|
26
|
+
effect.setOffset(5, 5) #影の大きさ
|
27
|
+
effect.setBlurRadius(20) #影のぼやけ具合
|
28
|
+
setGraphicsEffect(effect)
|
29
|
+
resize(image.width, image.height)
|
26
30
|
@offset = Qt::Point.new
|
27
31
|
@left = false
|
28
32
|
end
|
@@ -55,4 +59,9 @@
|
|
55
59
|
これならocraでexe化できます。(ただし、とても時間がかかる。)
|
56
60
|
起動にも時間がかかるので、Rubyにこだわらなければ他の言語で作った方がよさげです。
|
57
61
|
上のコードで、非矩形ウィンドウの作成とタイトルバーがない状態での
|
58
|
-
ドラッグ移動ができるようになっています。
|
62
|
+
ドラッグ移動ができるようになっています。
|
63
|
+
|
64
|
+
参考
|
65
|
+
[Qtでデスクトップマスコット的なのを実現する方法](http://amagitakayosi.hatenablog.com/entry/20121212/qt_mas)
|
66
|
+
[Moving object with mouse](http://stackoverflow.com/questions/11172420/moving-object-with-mouse)
|
67
|
+
|
3
修正
answer
CHANGED
@@ -52,7 +52,7 @@
|
|
52
52
|
app.exec
|
53
53
|
```
|
54
54
|
qtbindingsというgemを利用します。
|
55
|
-
これなら
|
55
|
+
これならocraでexe化できます。(ただし、とても時間がかかる。)
|
56
56
|
起動にも時間がかかるので、Rubyにこだわらなければ他の言語で作った方がよさげです。
|
57
57
|
上のコードで、非矩形ウィンドウの作成とタイトルバーがない状態での
|
58
58
|
ドラッグ移動ができるようになっています。
|
2
修正
answer
CHANGED
@@ -53,6 +53,6 @@
|
|
53
53
|
```
|
54
54
|
qtbindingsというgemを利用します。
|
55
55
|
これならOCRAでexe化できます。(ただし、とても時間がかかる。)
|
56
|
-
起動にも時間がかかるので、Rubyにこだわらなければ
|
56
|
+
起動にも時間がかかるので、Rubyにこだわらなければ他の言語で作った方がよさげです。
|
57
57
|
上のコードで、非矩形ウィンドウの作成とタイトルバーがない状態での
|
58
58
|
ドラッグ移動ができるようになっています。
|
1
修正
answer
CHANGED
@@ -5,4 +5,54 @@
|
|
5
5
|
|
6
6
|
これらのサイトのおかげでやりたかったことができました。
|
7
7
|
|
8
|
-
これからC#の勉強をしようと思います。
|
8
|
+
これからC#の勉強をしようと思います。
|
9
|
+
|
10
|
+
#追記
|
11
|
+
```Ruby
|
12
|
+
#encoding: utf-8
|
13
|
+
require"qt"
|
14
|
+
|
15
|
+
class DesktopMascot < Qt::Label
|
16
|
+
def initialize
|
17
|
+
super
|
18
|
+
image = Qt::Pixmap.new("イメージ.png")
|
19
|
+
setPixmap(image)
|
20
|
+
resize(image.width, image.height)
|
21
|
+
setStyleSheet("background:transparent; border: none;")
|
22
|
+
setAttribute(Qt::WA_TranslucentBackground)
|
23
|
+
setWindowFlags(Qt::FramelessWindowHint)
|
24
|
+
setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint)
|
25
|
+
setScaledContents(true)
|
26
|
+
@offset = Qt::Point.new
|
27
|
+
@left = false
|
28
|
+
end
|
29
|
+
def mousePressEvent(event)
|
30
|
+
if event.button() == Qt::LeftButton
|
31
|
+
@offset = event.pos()
|
32
|
+
@left = true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
def mouseMoveEvent(event)
|
36
|
+
if @left == true
|
37
|
+
move(mapToParent(event.pos() - @offset))
|
38
|
+
@lastpoint = event.pos()
|
39
|
+
end
|
40
|
+
end
|
41
|
+
def mouseReleaseEvent(event)
|
42
|
+
if event.button() == Qt::LeftButton
|
43
|
+
@left = false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
app = Qt::Application.new(ARGV)
|
49
|
+
window = DesktopMascot.new
|
50
|
+
window.show
|
51
|
+
|
52
|
+
app.exec
|
53
|
+
```
|
54
|
+
qtbindingsというgemを利用します。
|
55
|
+
これならOCRAでexe化できます。(ただし、とても時間がかかる。)
|
56
|
+
起動にも時間がかかるので、RubyにこだわらなければC#で作った方がよさげです。
|
57
|
+
上のコードで、非矩形ウィンドウの作成とタイトルバーがない状態での
|
58
|
+
ドラッグ移動ができるようになっています。
|