Development/Tutorials/Qt4 Ruby Tutorial/Chapter 04

Development | Tutorials | Qt4 Ruby Tutorial
Revision as of 18:03, 28 December 2009 by Alisha (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Contents

Development/Tutorials/Qt4 Ruby Tutorial/Chapter 4


Let There Be Widgets
Tutorial Series   Qt4 Ruby Tutorial
Previous   Tutorial 3 - Family Values
What's Next   Tutorial 5 - Building Blocks
Further Reading   n/a

Let There Be Widgets

Qt4 Ruby Tutorial Screenshot 4.png

Files:

Overview

This example shows how to create your own widget, and describes how to control the minimum and maximum sizes of a widget.

require 'Qt4'

class MyWidget < Qt::Widget

 def initialize(parent = nil)
   super
   setFixedSize(200, 120)
   quit = Qt::PushButton.new(tr('Quit'), self)
   quit.setGeometry(62, 40, 75, 30)
   quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold))
   connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()'))
 end

end

app = Qt::Application.new(ARGV)

widget = MyWidget.new() widget.show()

app.exec()

Line by Line Walkthrough


KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal