Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby Desktop Apps with Qt

Ruby Desktop Apps with Qt

Writing desktop applications using ruby and Qt

ynonperek

June 25, 2012
Tweet

More Decks by ynonperek

Other Decks in Technology

Transcript

  1. Desktop Apps • Office • Web Browser • Skype •

    IDE • Torrent / FTP Client Monday, June 25, 12
  2. Mature and Widely Used • Choosing a widely used framework

    ensures that you won’t run into bumps when scaling up • Choosing a framework with future ensures it won’t suddenly disappear Monday, June 25, 12
  3. Cross Platform • The more the better • Code once,

    look good everywhere Monday, June 25, 12
  4. Cross Language • C++ • Java • Ruby • Perl

    • Python Monday, June 25, 12
  5. Choose Qt • Cross Platform • Cross Languages • Awesome

    Tools • Here To Stay Monday, June 25, 12
  6. Famous Qt Apps • Skype • Google Earth • KDE

    • KOffice • VLC • PhantomJS Monday, June 25, 12
  7. QtRuby In Action • Installation • UI Design • Add

    Actions • Use Stock Dialogs • Code: http://github.com/ynonp/ ruby-underground-talk Monday, June 25, 12
  8. Installation: Mac/Linux • Install Qt SDK from Nokia • gem

    install qtbindings • Details: https://github.com/ryanmelt/ qtbindings Monday, June 25, 12
  9. Hello QtRuby 1 require 'Qt' 2 3 app = Qt::Application.new

    ( ARGV ) 4 5 b = Qt::PushButton.new( "DIE ALL HUMANS" ) 6 b.connect ( SIGNAL :clicked ) { app.exit } 7 8 b.show 9 app.exec 10 Monday, June 25, 12
  10. Signals & Slots • Signals are Semantic Events • Slots

    are handlers (methods or blocks) • signal -----> slot Monday, June 25, 12
  11. Object Trees • Each Qt::Widget may contain other widgets •

    Pass a container (parent) to initialize • Use layouts to determine ordering Monday, June 25, 12
  12. No Layout 1 require 'Qt' 2 3 app = Qt::Application.new

    ( ARGV ) 4 5 w = Qt::Widget.new 6 b = Qt::PushButton.new( "Ouch! That hurt" , w) 7 c = Qt::PushButton.new("9", w) 8 9 w.show 10 11 app.exec 12 Monday, June 25, 12
  13. With Layout 1 require 'Qt' 2 3 app = Qt::Application.new

    ( ARGV ) 4 5 w = Qt::Widget.new 6 7 b = Qt::PushButton.new( "Ouch! That hurt") 8 c = Qt::PushButton.new("9") 9 10 l = Qt::VBoxLayout.new( w ) 11 l.addWidget ( b ) 12 l.addWidget ( c ) 13 14 w.show 15 16 app.exec 17 Monday, June 25, 12
  14. UI Design • Run Qt Designer • Make GUI •

    Save as .ui file • Convert to ruby with: rbuic4 file.ui -x -o file_ui.rb Monday, June 25, 12
  15. QtRuby First App • Rapid UI with Designer • Easy

    layouts with Qt’s Layout Managers • Extensive library of Widgets and Stock Dialogs Monday, June 25, 12
  16. Add Some Color • Use css-like style sheets to style

    your app • Syntax: http://qt-project.org/ doc/qt-4.8/stylesheet- syntax.html Monday, June 25, 12