# QtRuby: system tray

**URL:** <https://www.ruby-forum.com/t/qtruby-system-tray/151824>\
**Category:** Ruby\
**Created:** [October 26, 2008, 12:43pm UTC](https://www.ruby-forum.com/t/qtruby-system-tray/151824 "2008-10-26T12:43:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bizzz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bizzz](https://www.ruby-forum.com/u/bizzz)\
**Post date:** [October 26, 2008, 12:43pm UTC](https://www.ruby-forum.com/t/qtruby-system-tray/151824/1 "2008-10-26T12:43:05Z")

</div>

Hello, fellow rubyists!  
I need an ability to hide my Qt-based app in tray and unhide it back 🙂  
I’ve read C examples at  
[http://doc.trolltech.com/4.2/desktop-systray.html](http://doc.trolltech.com/4.2/desktop-systray.html)  
but couldn’t understand it enough to translate it in ruby.  
If someone has done this before or can explain how to use the above  
example, please help me.

Andrew

---

<div class="post-metadata">

**Author:** ![bizzz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bizzz](https://www.ruby-forum.com/u/bizzz)\
**Post date:** [October 26, 2008, 6:40pm UTC](https://www.ruby-forum.com/t/qtruby-system-tray/151824/2 "2008-10-26T18:40:35Z")

</div>

On Sun, 26 Oct 2008 06:42:49 -0500, Andrew L. wrote:

> Hello, fellow rubyists!  
> I need an ability to hide my Qt-based app in tray and unhide it back 🙂  
> I’ve read C examples at  
> [http://doc.trolltech.com/4.2/desktop-systray.html](http://doc.trolltech.com/4.2/desktop-systray.html) but couldn’t  
> understand it enough to translate it in ruby. If someone has done this  
> before or can explain how to use the above example, please help me.

It’s all about the QSystemTrayIcon class. Use the #hide and #show  
methods  
to hide it and make it reappear.

–Ken

---

<div class="post-metadata">

**Author:** ![bizzz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bizzz](https://www.ruby-forum.com/u/bizzz)\
**Post date:** [October 26, 2008, 8:15pm UTC](https://www.ruby-forum.com/t/qtruby-system-tray/151824/3 "2008-10-26T20:15:31Z")

</div>

Ken B. wrote:

> It’s all about the QSystemTrayIcon class. Use the #hide and #show  
> methods  
> to hide it and make it reappear.  
> Thank you, Ken, i started to get it, but here’s a problem:  
> t = Qt::SystemTrayIcon.new  
> t.setIcon(‘icon.png’)  
> results in error:  
> `method_missing': undefined method`setIcon’ for #\<Qt::SystemTrayIcon:

---

<div class="post-metadata">

**Author:** ![bizzz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bizzz](https://www.ruby-forum.com/u/bizzz)\
**Post date:** [October 26, 2008, 8:28pm UTC](https://www.ruby-forum.com/t/qtruby-system-tray/151824/4 "2008-10-26T20:28:55Z")

</div>

Thank you, Stefano!  
That worked!

---

<div class="post-metadata">

**Author:** ![bizzz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bizzz](https://www.ruby-forum.com/u/bizzz)\
**Post date:** [October 26, 2008, 8:23pm UTC](https://www.ruby-forum.com/t/qtruby-system-tray/151824/5 "2008-10-26T20:23:44Z")

</div>

Alle Sunday 26 October 2008, Andrew L. ha scritto:

> Ken B. wrote:
> 
> > It’s all about the QSystemTrayIcon class. Use the #hide and #show  
> > methods  
> > to hide it and make it reappear.
> 
> Thank you, Ken, i started to get it, but here’s a problem:  
> t = Qt::SystemTrayIcon.new  
> t.setIcon(‘icon.png’)  
> results in error:  
> `method_missing': undefined method`setIcon’ for #\<Qt::SystemTrayIcon:

setIcon requires a Qt::Icon, not the name of the icon file. You can do  
this:

t.setIcon(Qt::Icon.new(‘icon.png’))

You can also write this in a more rubish way:

t.icon = Qt::Icon.new(‘icon.png’)

Stefano
