<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Thursday Night &#187; QT/KDE</title>
	<atom:link href="http://blog.paulbetts.org/index.php/category/programming/qtkde/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.paulbetts.org</link>
	<description>Paul Betts's personal website / blog / what-have-you</description>
	<lastBuildDate>Tue, 27 Sep 2011 21:17:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Qt4 Ruby and Metaprogramming 0.1 &#8211; Wiring up slots automatically</title>
		<link>http://blog.paulbetts.org/index.php/2007/09/08/qt4-ruby-and-metaprogramming-01-wiring-up-slots-automatically/</link>
		<comments>http://blog.paulbetts.org/index.php/2007/09/08/qt4-ruby-and-metaprogramming-01-wiring-up-slots-automatically/#comments</comments>
		<pubDate>Sun, 09 Sep 2007 03:20:14 +0000</pubDate>
		<dc:creator>Paul Betts</dc:creator>
				<category><![CDATA[QT/KDE]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.paulbetts.org/index.php/2007/09/08/qt4-ruby-and-metaprogramming-01-wiring-up-slots-automatically/</guid>
		<description><![CDATA[In my attempts to learn Qt 4 and QtRuby, it&#8217;s pretty obvious that there&#8217;s a huge potential for doing Rails-like things, such as declaration by convention. To this end, here&#8217;s an example of what you can do with the code I&#8217;m writing: this loads a UI file and wires something up to the Open action: [...]]]></description>
			<content:encoded><![CDATA[<p>
In my attempts to learn Qt 4 and QtRuby, it&#8217;s pretty obvious that there&#8217;s a huge potential for doing Rails-like things, such as declaration by convention. To this end, here&#8217;s an example of what you can do with the code I&#8217;m writing: this loads a UI file and wires something up to the Open action:
</p>
<style type="text/css">/* GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter) */.ch_code_container  {font-family: monospace;font-size: 10pxheight:100%;}.ch_code_container .imp {font-weight: bold; color: red;}.ch_code_container .kw1 {color:#9966CC; font-weight:bold;}.ch_code_container .kw2 {color:#0000FF; font-weight:bold;}.ch_code_container .kw3 {color:#CC0066; font-weight:bold;}.ch_code_container .co1 {color:#008000; font-style:italic;}.ch_code_container .coMULTI {color:#000080; font-style:italic;}.ch_code_container .es0 {color:#000099;}.ch_code_container .br0 {color:#006600; font-weight:bold;}.ch_code_container .st0 {color:#996600;}.ch_code_container .nu0 {color:#006666;}.ch_code_container .me1 {color:#9900CC;}</style>
<div class="ch_code_container" style="font-family: monospace;font-size: 10pxheight:100%;"><span class="kw3">require</span> &#8216;Qt&#8217;</p>
<p><span class="kw1">class</span> ActionOpenHandler &lt; Qt::Object<br />
&nbsp; &nbsp; slots <span class="st0">&quot;on_activated()&quot;</span></p>
<p>&nbsp; &nbsp; <span class="kw1">def</span> initialize<span class="br0">&#40;</span>main = <span class="kw2">nil</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">super</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @main = main<br />
&nbsp; &nbsp; <span class="kw1">end</span></p>
<p>&nbsp; &nbsp; <span class="kw1">def</span> on_activated<br />
&nbsp; &nbsp; &nbsp; &nbsp; path = <span class="kw2">nil</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Qt::FileDialog.<span class="me1">new</span> <span class="kw1">do</span> |fd|<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path = fd.<span class="me1">get_open_file_name</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">return</span> <span class="kw1">unless</span> path</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; text = <span class="kw2">nil</span>;&nbsp;File.<span class="kw3">open</span><span class="br0">&#40;</span>path, &#8216;r&#8217;<span class="br0">&#41;</span> <span class="br0">&#123;</span>|f| text = f.<span class="me1">read</span><span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @main.<span class="me1">findChild</span><span class="br0">&#40;</span>Qt::TextEdit, <span class="st0">&quot;textBrowser&quot;</span><span class="br0">&#41;</span>.<span class="me1">text</span> = text<br />
&nbsp; &nbsp; <span class="kw1">end</span><br />
<span class="kw1">end</span></p>
<p>a = Qt::Application.<span class="me1">new</span><span class="br0">&#40;</span>ARGV<span class="br0">&#41;</span><br />
QtSuperLoader.<span class="me1">new</span>.<span class="me1">initialize_and_hook</span><span class="br0">&#40;</span><span class="st0">&quot;./main.ui&quot;</span><span class="br0">&#41;</span>.<span class="me1">show</span><br />
a.<span class="kw3">exec</span></div>
<p>
Next, I&#8217;m seeking to replace the ugly line <code>"@main.findChild(Qt::TextEdit, "textBrowser").text = text"</code> with the more palatable <code>"@main.text_browser.text = text"</code>. However, this is a bit more tricky, because findChild creates strongly-typed objects &#8211; there may be some trickery to get around it though involving QMetaObject.
</p>
<p>
Here&#8217;s the files, including the code that supports it all: <a href="http://www.paulbetts.org/projects/qttest.rb">qttest.rb</a> and <a href="http://www.paulbetts.org/projects/Translator.ui">Translator.ui</a>
</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.paulbetts.org/index.php/2007/09/08/qt4-ruby-and-metaprogramming-01-wiring-up-slots-automatically/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t worry, I haven&#8217;t forgotten QtRuby on Win32!</title>
		<link>http://blog.paulbetts.org/index.php/2007/07/22/dont-worry-i-havent-forgotten-qtruby-on-win32/</link>
		<comments>http://blog.paulbetts.org/index.php/2007/07/22/dont-worry-i-havent-forgotten-qtruby-on-win32/#comments</comments>
		<pubDate>Mon, 23 Jul 2007 01:32:45 +0000</pubDate>
		<dc:creator>Paul Betts</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[QT/KDE]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.paulbetts.org/index.php/2007/07/22/dont-worry-i-havent-forgotten-qtruby-on-win32/</guid>
		<description><![CDATA[I was planning on posting the same kind of tutorial for Win32 for using QtRuby, but I&#8217;m currently stuck as to how to get it to build. After fighting with random build glitches for three hours or so (making progress, slowly), I&#8217;m currently stuck here: /* GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter) */.ch_code_container {font-family: monospace;font-size: [...]]]></description>
			<content:encoded><![CDATA[<p>
I was planning on posting the same kind of tutorial for Win32 for using QtRuby, but I&#8217;m currently stuck as to how to get it to build. After fighting with random build glitches for three hours or so (making progress, slowly), I&#8217;m currently stuck here:</p>
<style type="text/css">/* GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter) */.ch_code_container  {font-family: monospace;font-size: 10pxheight:100%;}.ch_code_container .imp {font-weight: bold; color: red;}.ch_code_container .kw1 {color: #b1b100;}.ch_code_container .kw3 {color: #000066;}.ch_code_container .co1 {color: #808080; font-style: italic;}.ch_code_container .es0 {color: #000099; font-weight: bold;}.ch_code_container .br0 {color: #66cc66;}.ch_code_container .st0 {color: #ff0000;}.ch_code_container .nu0 {color: #cc66cc;}.ch_code_container .re0 {color: #0000ff;}.ch_code_container .re1 {color: #0000ff;}.ch_code_container .re2 {color: #0000ff;}</style>
<div class="ch_code_container" style="font-family: monospace;font-size: 10pxheight:100%;">Compiled with:<br />
C:/MinGW/bin/g++.exe&nbsp; &nbsp;-IC:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/include/QtDBus -IC:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/include/QtTest<br />
&nbsp;-IC:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/include/QtUiTools -IC:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/include/QtScript -IC:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/<span class="kw1">in</span><br />
clude/QtSvg -IC:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/include/QtXml -IC:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/include/QtSql -IC:/Qt/<span class="nu0">4.3</span>.<br />
<span class="nu0">0</span>/include/QtOpenGL -IC:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/include/QtNetwork -IC:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/include/QtDesig<br />
ner -IC:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/include/QtDesigner -IC:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/include/QtAssistant -IC:/Qt/<span class="nu0">4</span><br />
.<span class="nu0">3.0</span>/include/Qt3Support -IC:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/include/QtGui -IC:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/include/QtCore<br />
&nbsp;-IC:\Qt\<span class="nu0">4.3</span><span class="nu0">.0</span>\mkspecs/default -IC:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/include/Qt -IC:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/include&nbsp; C<br />
:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/lib/libQtCore4.a C:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/lib/libQtNetwork4.a C:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/lib/libQ<br />
tSql4.a C:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/lib/libQtXml4.a C:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/lib/libQtGui4.a C:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/lib/<br />
libQtUiTools.a C:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/lib/libQtSvg4.a C:/Qt/<span class="nu0">4.3</span><span class="nu0">.0</span>/lib/libQtOpenGL4.a C:/Qt/<br />
<span class="nu0">4.3</span><span class="nu0">.0</span>/lib/libQt3Support4.a&nbsp; -o C:\Users\paulbe\AppData\Local\Temp/<span class="nu0">3428</span>-qtguess C<br />
:\Users\paulbe\AppData\Local\Temp/<span class="nu0">3428</span>-qtguess.cpp<br />
Compiler output:<br />
C:\Users\paulbe\AppData\Local\Temp/<span class="nu0">3428</span>-qtguess.cpp:<span class="nu0">8</span>:<span class="nu0">2</span>: warning: no newline at<br />
end of file<br />
C:\Users\paulbe\AppData\Local\Temp/ccMxaaaa.o<span class="br0">&#40;</span>.text+0&#215;147<span class="br0">&#41;</span>:<span class="nu0">3428</span>-qtguess.cpp: <br />
undefined reference to `_imp___ZN12QApplicationC1ERiPPci<span class="st0">&#8216;<br />
C:<span class="es0">\U</span>sers<span class="es0">\p</span>aulbe<span class="es0">\A</span>ppData<span class="es0">\L</span>ocal<span class="es0">\T</span>emp/ccMxaaaa.o(.text+0&#215;154):3428-qtguess.cpp: <br />
undefined reference to `QApplication::~QApplication()&#8217;</span><br />
collect2: ld returned <span class="nu0">1</span> <span class="kw3">exit</span> status</div>
<p>Thoughts? It looks like I&#8217;ve got some sort of compiler mismatch (one library compiled with MSVC and one compiled with MinGW, probably). I have no idea where though, I&#8217;m 85% sure that Qt is compiled with MinGW
</p>
<p><b>Update:</b> Alright, the new plan is to compile everything from scratch, and see if I can get some better results.</p>
<p><b>Update 2:</b> It&#8217;s definitely the compiler difference:</p>
<style type="text/css">/* GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter) */.ch_code_container  {font-family: monospace;font-size: 10pxheight:100%;}.ch_code_container .imp {font-weight: bold; color: red;}.ch_code_container .kw1 {color: #b1b100;}.ch_code_container .kw3 {color: #000066;}.ch_code_container .co1 {color: #808080; font-style: italic;}.ch_code_container .es0 {color: #000099; font-weight: bold;}.ch_code_container .br0 {color: #66cc66;}.ch_code_container .st0 {color: #ff0000;}.ch_code_container .nu0 {color: #cc66cc;}.ch_code_container .re0 {color: #0000ff;}.ch_code_container .re1 {color: #0000ff;}.ch_code_container .re2 {color: #0000ff;}</style>
<div class="ch_code_container" style="font-family: monospace;font-size: 10pxheight:100%;">&gt; objdump -x C:\Qt\<span class="nu0">4.3</span><span class="nu0">.0</span>\lib\libQtGui4.a</p>
<p><span class="br0">&#123;</span> Snip! <span class="br0">&#125;</span></p>
<p>SYMBOL TABLE:<br />
<span class="br0">&#91;</span>&nbsp; <span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#40;</span>sec&nbsp; <span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#40;</span>fl 0&#215;00<span class="br0">&#41;</span><span class="br0">&#40;</span>ty&nbsp; &nbsp;<span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#40;</span>scl&nbsp; &nbsp;<span class="nu0">3</span><span class="br0">&#41;</span> <span class="br0">&#40;</span>nx <span class="nu0">0</span><span class="br0">&#41;</span> 0&#215;00000000 .text<br />
<span class="br0">&#91;</span>&nbsp; <span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#40;</span>sec&nbsp; <span class="nu0">2</span><span class="br0">&#41;</span><span class="br0">&#40;</span>fl 0&#215;00<span class="br0">&#41;</span><span class="br0">&#40;</span>ty&nbsp; &nbsp;<span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#40;</span>scl&nbsp; &nbsp;<span class="nu0">3</span><span class="br0">&#41;</span> <span class="br0">&#40;</span>nx <span class="nu0">0</span><span class="br0">&#41;</span> 0&#215;00000000 .idata$<span class="nu0">7</span><br />
<span class="br0">&#91;</span>&nbsp; <span class="nu0">2</span><span class="br0">&#93;</span><span class="br0">&#40;</span>sec&nbsp; <span class="nu0">3</span><span class="br0">&#41;</span><span class="br0">&#40;</span>fl 0&#215;00<span class="br0">&#41;</span><span class="br0">&#40;</span>ty&nbsp; &nbsp;<span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#40;</span>scl&nbsp; &nbsp;<span class="nu0">3</span><span class="br0">&#41;</span> <span class="br0">&#40;</span>nx <span class="nu0">0</span><span class="br0">&#41;</span> 0&#215;00000000 .idata$<span class="nu0">5</span><br />
<span class="br0">&#91;</span>&nbsp; <span class="nu0">3</span><span class="br0">&#93;</span><span class="br0">&#40;</span>sec&nbsp; <span class="nu0">4</span><span class="br0">&#41;</span><span class="br0">&#40;</span>fl 0&#215;00<span class="br0">&#41;</span><span class="br0">&#40;</span>ty&nbsp; &nbsp;<span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#40;</span>scl&nbsp; &nbsp;<span class="nu0">3</span><span class="br0">&#41;</span> <span class="br0">&#40;</span>nx <span class="nu0">0</span><span class="br0">&#41;</span> 0&#215;00000000 .idata$<span class="nu0">4</span><br />
<span class="br0">&#91;</span>&nbsp; <span class="nu0">4</span><span class="br0">&#93;</span><span class="br0">&#40;</span>sec&nbsp; <span class="nu0">5</span><span class="br0">&#41;</span><span class="br0">&#40;</span>fl 0&#215;00<span class="br0">&#41;</span><span class="br0">&#40;</span>ty&nbsp; &nbsp;<span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#40;</span>scl&nbsp; &nbsp;<span class="nu0">3</span><span class="br0">&#41;</span> <span class="br0">&#40;</span>nx <span class="nu0">0</span><span class="br0">&#41;</span> 0&#215;00000000 .idata$<span class="nu0">6</span><br />
<span class="br0">&#91;</span>&nbsp; <span class="nu0">5</span><span class="br0">&#93;</span><span class="br0">&#40;</span>sec&nbsp; <span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#40;</span>fl 0&#215;00<span class="br0">&#41;</span><span class="br0">&#40;</span>ty&nbsp; &nbsp;<span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#40;</span>scl&nbsp; &nbsp;<span class="nu0">2</span><span class="br0">&#41;</span> <span class="br0">&#40;</span>nx <span class="nu0">0</span><span class="br0">&#41;</span> 0&#215;00000000 __ZN12QApplicationC2ERiPPci<br />
<span class="br0">&#91;</span>&nbsp; <span class="nu0">6</span><span class="br0">&#93;</span><span class="br0">&#40;</span>sec&nbsp; <span class="nu0">3</span><span class="br0">&#41;</span><span class="br0">&#40;</span>fl 0&#215;00<span class="br0">&#41;</span><span class="br0">&#40;</span>ty&nbsp; &nbsp;<span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#40;</span>scl&nbsp; &nbsp;<span class="nu0">2</span><span class="br0">&#41;</span> <span class="br0">&#40;</span>nx <span class="nu0">0</span><span class="br0">&#41;</span> 0&#215;00000000 __imp___ZN12QApplicationC2ERiPPci<br />
<span class="br0">&#91;</span>&nbsp; <span class="nu0">7</span><span class="br0">&#93;</span><span class="br0">&#40;</span>sec&nbsp; <span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#40;</span>fl 0&#215;00<span class="br0">&#41;</span><span class="br0">&#40;</span>ty&nbsp; &nbsp;<span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#40;</span>scl&nbsp; &nbsp;<span class="nu0">2</span><span class="br0">&#41;</span> <span class="br0">&#40;</span>nx <span class="nu0">0</span><span class="br0">&#41;</span> 0&#215;00000000 __head_QtGui4_dll</div>
<p> The compiler&#8217;s looking for <code>__imp___ZN12QApplicationC1ERiPPci</code>, but the precompiled library has C2. I don&#8217;t understand why Qt&#8217;s distributing a busted library &#8211; this would break even their samples in straight C++ &#8211; it&#8217;s possible that Mingw updated behind their back though.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.paulbetts.org/index.php/2007/07/22/dont-worry-i-havent-forgotten-qtruby-on-win32/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross-platform UI with Qt4 and Ruby &#8211; Mac/Linux HOWTO</title>
		<link>http://blog.paulbetts.org/index.php/2007/07/22/cross-platform-ui-with-qt4-and-ruby-maclinux-howto/</link>
		<comments>http://blog.paulbetts.org/index.php/2007/07/22/cross-platform-ui-with-qt4-and-ruby-maclinux-howto/#comments</comments>
		<pubDate>Sun, 22 Jul 2007 23:03:41 +0000</pubDate>
		<dc:creator>Paul Betts</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[QT/KDE]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.paulbetts.org/index.php/2007/07/22/cross-platform-ui-with-qt4-and-ruby-maclinux-howto/</guid>
		<description><![CDATA[Today I&#8217;ve spent the day working on figuring out how to make UIs using Ruby and Qt4. If you haven&#8217;t heard of it, Qt4 is an awesome UI framework written in C++. Since C++ is way too much work, some great KDE devs wrote a bindings generator for Qt4 called qt4-qtruby. While this package is [...]]]></description>
			<content:encoded><![CDATA[<p>
Today I&#8217;ve spent the day working on figuring out how to make UIs using Ruby and Qt4. If you haven&#8217;t heard of it, <a href="http://trolltech.com/products/qt">Qt4<a /> is an awesome UI framework written in C++. Since C++ is way too much work, some great KDE devs wrote a bindings generator for Qt4 called </a><a href="http://developer.kde.org/language-bindings/ruby/index.html">qt4-qtruby</a>. While this package is fairly &#8220;linuxy&#8221;, it&#8217;s pretty easy to build it on Mac OS X too, making it possible to write GUI programs for OS X without having to delve into RubyCocoa which has too much hackiness (in my opinion), or even worse, Objective C. Furthermore, your code that you write on OS X will look great on Windows and Linux too!
</p>
<h2>Starting from scratch</h2>
<p>
First, install Ruby. If you&#8217;re using Linux, you&#8217;ll probably use the package manager to install Ruby <b>and the Ruby development libraries!</b> (Ubuntu will run <code>sudo apt-get install ruby irb ruby-dev</code>) OS X Tiger ships with Ruby by default, but you&#8217;ll want to install an updated version, via the <a href="http://rubyosx.rubyforge.org/">Ruby one-click installer</a>, then disable the old Ruby by using the following command:</p>
<style type="text/css">/* GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter) */.ch_code_container  {font-family: monospace;font-size: 10pxheight:100%;}.ch_code_container .imp {font-weight: bold; color: red;}.ch_code_container .kw1 {color: #b1b100;}.ch_code_container .kw3 {color: #000066;}.ch_code_container .co1 {color: #808080; font-style: italic;}.ch_code_container .es0 {color: #000099; font-weight: bold;}.ch_code_container .br0 {color: #66cc66;}.ch_code_container .st0 {color: #ff0000;}.ch_code_container .nu0 {color: #cc66cc;}.ch_code_container .re0 {color: #0000ff;}.ch_code_container .re1 {color: #0000ff;}.ch_code_container .re2 {color: #0000ff;}</style>
<div class="ch_code_container" style="font-family: monospace;font-size: 10pxheight:100%;"><span class="co1">## Only do this on Mac! Linux doesn&#8217;t need this nonsense ##</span><br />
touch ~/.bashrc &amp;&amp; <span class="kw3">echo</span> <span class="st0">&#8216;export PATH=&quot;/usr/local/bin:$PATH&quot;&#8217;</span> &gt;&gt; ~/.bashrc<br />
sudo mv /usr/lib/libruby<span class="nu0">.1</span>.dylib /usr/lib/_libruby<span class="nu0">.1</span>.dylib</div>
</p>
<h2>Installing Qt4 and QtRuby</h2>
<p>
First, install Qt4 by using your package manager on Linux (in Ubuntu, use the <code>-kdecopy</code> packages, they are more up to date), or by downloading the DMG from the <a href="http://trolltech.com/developer/downloads/qt/mac">Qt/Mac Open Source Edition Download</a> page. You&#8217;ll also need <a href="http://www.macports.org/">MacPorts</a> (and by proxy, the XCode tools). Also, download the <a href="http://rubyforge.org/frs/?group_id=181&#038;release_id=12479">Qt4 Ruby bindings source code</a> from Rubyforge and save it to the Desktop.
</p>
<p>
Here&#8217;s the cool thing about QtRuby, and the advantage of building it from source: the build framework for QtRuby scans through whatever version of Qt you have installed, and <i>dynamically</i> builds the bindings. This means, there&#8217;s no waiting for new Qt features to be available in Ruby, it&#8217;s always up-to-date! Which is quite handy, because it seems like every minor version of Qt has new cool stuff.
</p>
<p>
Next, we have to do a bit of hackery &#8211; unfortunately, there&#8217;s no easy way to install QtRuby but it&#8217;s not so hard. Here&#8217;s what you&#8217;ll run:</p>
<style type="text/css">/* GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter) */.ch_code_container  {font-family: monospace;font-size: 10pxheight:100%;}.ch_code_container .imp {font-weight: bold; color: red;}.ch_code_container .kw1 {color: #b1b100;}.ch_code_container .kw3 {color: #000066;}.ch_code_container .co1 {color: #808080; font-style: italic;}.ch_code_container .es0 {color: #000099; font-weight: bold;}.ch_code_container .br0 {color: #66cc66;}.ch_code_container .st0 {color: #ff0000;}.ch_code_container .nu0 {color: #cc66cc;}.ch_code_container .re0 {color: #0000ff;}.ch_code_container .re1 {color: #0000ff;}.ch_code_container .re2 {color: #0000ff;}</style>
<div class="ch_code_container" style="font-family: monospace;font-size: 10pxheight:100%;"><span class="kw3">cd</span> ~/Desktop<br />
sudo port install cmake&nbsp; &nbsp;<span class="co1">## CMake is a cool build system</span><br />
tar -xzvf qt4-qtruby<span class="nu0">-1.4</span><span class="nu0">.9</span>.tgz &amp;&amp; <span class="kw3">cd</span> ./qt4-qtruby<span class="nu0">-1.4</span><span class="nu0">.9</span><br />
cmake .<br />
make &amp;&amp; sudo make install</div>
</p>
<h2>Try it out!</h2>
<p>
Once you&#8217;ve got it built, try this sample code to see some of the new features in Qt 4.3 &#8211; this code will run a natively-styled wizard in Windows, Mac, and Linux without any changes! Unfortunately, this code isn&#8217;t very elegant or Ruby-like, but it&#8217;s a base that someone could write a really elegant UI framework over like RoR. </p>
<style type="text/css">/* GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter) */.ch_code_container  {font-family: monospace;font-size: 10pxheight:100%;}.ch_code_container .imp {font-weight: bold; color: red;}.ch_code_container .kw1 {color:#9966CC; font-weight:bold;}.ch_code_container .kw2 {color:#0000FF; font-weight:bold;}.ch_code_container .kw3 {color:#CC0066; font-weight:bold;}.ch_code_container .co1 {color:#008000; font-style:italic;}.ch_code_container .coMULTI {color:#000080; font-style:italic;}.ch_code_container .es0 {color:#000099;}.ch_code_container .br0 {color:#006600; font-weight:bold;}.ch_code_container .st0 {color:#996600;}.ch_code_container .nu0 {color:#006666;}.ch_code_container .me1 {color:#9900CC;}</style>
<div class="ch_code_container" style="font-family: monospace;font-size: 10pxheight:100%;"><span class="kw3">require</span> &#8216;Qt&#8217;<br />
a = Qt::Application.<span class="me1">new</span><span class="br0">&#40;</span>ARGV<span class="br0">&#41;</span></p>
<p><span class="kw1">def</span> create_intro_page<br />
&nbsp; &nbsp; &nbsp; &nbsp; page = Qt::WizardPage.<span class="me1">new</span> <span class="kw1">do</span> |p|<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">p</span>.<span class="me1">title</span> = <span class="st0">&quot;Introduction&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; label = Qt::Label.<span class="me1">new</span><span class="br0">&#40;</span><span class="st0">&quot;This is a wizard!&quot;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; label.<span class="me1">word_wrap</span> = <span class="kw2">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; layout = Qt::VBoxLayout.<span class="me1">new</span> <span class="kw1">do</span> |v|<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v.<span class="me1">add_widget</span><span class="br0">&#40;</span>label<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; page.<span class="me1">layout</span> = layout<br />
&nbsp; &nbsp; &nbsp; &nbsp; page<br />
<span class="kw1">end</span></p>
<p>wiz = Qt::Wizard.<span class="me1">new</span> <span class="kw1">do</span> |x|<br />
&nbsp; &nbsp; &nbsp; &nbsp; x.<span class="me1">add_page</span><span class="br0">&#40;</span>create_intro_page<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x.<span class="me1">set_window_title</span><span class="br0">&#40;</span><span class="st0">&quot;Test Wizard&quot;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x.<span class="me1">show</span><br />
<span class="kw1">end</span></p>
<p>a.<span class="kw3">exec</span></div>
</p>
<p align="center">
<table>
<tr>
<td align="center">
<a href="http://blog.paulbetts.org/wp-photos/WizardOSX.png"><img src="http://blog.paulbetts.org/wp-photos/WizardOSX_Small.png" /></a><br />
<i>On Mac OS X</i>
</td>
<td align="center">
<a href="http://blog.paulbetts.org/wp-photos/WizardLinux.png"><img src="http://blog.paulbetts.org/wp-photos/WizardLinux_Small.png" /></a><br />
<i>On Linux</i>
</td>
</tr>
</table>
<h2>In summary:</h2>
<ol>
<li>Install a Ruby that doesn&#8217;t suck, and hack your environment so it works right</li>
<li>Install Qt and MacPorts</li>
<li>Build QtRuby and install it</li>
<li>Make UIs for all 3 platforms without hating your life</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.paulbetts.org/index.php/2007/07/22/cross-platform-ui-with-qt4-and-ruby-maclinux-howto/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Autotorrent 0.5.1 &#8211; This one is actually useful</title>
		<link>http://blog.paulbetts.org/index.php/2007/02/24/autotorrent-051-this-one-is-actually-useful/</link>
		<comments>http://blog.paulbetts.org/index.php/2007/02/24/autotorrent-051-this-one-is-actually-useful/#comments</comments>
		<pubDate>Sat, 24 Feb 2007 19:38:09 +0000</pubDate>
		<dc:creator>Paul Betts</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[QT/KDE]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.paulbetts.org/index.php/2007/02/24/autotorrent-051-this-one-is-actually-useful/</guid>
		<description><![CDATA[After reading the feedback on kde-apps.org as well as discovering how awesome KTorrent is, I&#8217;ve added some features to Autotorrent that should make it much more useful for people. First, I added support for other torrent programs, and I was able to make the KTorrent support really nice using DCOP. Basically, it means that once [...]]]></description>
			<content:encoded><![CDATA[<p>
After reading the feedback on kde-apps.org as well as discovering how awesome <a href="http://www.ktorrent.org">KTorrent</a> is, I&#8217;ve added some features to Autotorrent that should make it much more useful for people. First, I added support for other torrent programs, and I was able to make the KTorrent support really nice using DCOP.  Basically, it means that once you have a default directory set up, Autotorrent can silently add torrents without popping up the &#8220;OMG DO YOU WANT TO SAVE THIS?!&#8221; dialog.
</p>
<p align="center"><img src="http://blog.paulbetts.org/wp-photos/AutotorrentDialog.png" /><br />
<i>This dialog isn&#8217;t very pretty but that&#8217;s alright</i>
</p>
<p>
Next, after learning some basic <a href="http://developer.kde.org/language-bindings/ruby/index.html">QtRuby</a>, I managed to make a decent configuration dialog. It&#8217;s not very well spaced and it was a giant pain-in-the-ass to get what I wanted done, probably because I&#8217;m used to the GTK+ way of doing things, particularly when it comes to signals and slots. I&#8217;m totally biased, but I think the Qt way just involves a lot of extra declarations and isn&#8217;t nearly as Ruby-like as Ruby-GNOME2
</p>
<p><b>Update:</b> PS <a href="http://kde-apps.org/content/show.php?content=53391">here&#8217;s where you can download Autotorrent</a>. Oops.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.paulbetts.org/index.php/2007/02/24/autotorrent-051-this-one-is-actually-useful/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Porting apps to KDE4 &#8211; part 1</title>
		<link>http://blog.paulbetts.org/index.php/2006/12/06/porting-apps-to-kde4-part-1/</link>
		<comments>http://blog.paulbetts.org/index.php/2006/12/06/porting-apps-to-kde4-part-1/#comments</comments>
		<pubDate>Wed, 06 Dec 2006 15:47:49 +0000</pubDate>
		<dc:creator>Paul Betts</dc:creator>
				<category><![CDATA[QT/KDE]]></category>

		<guid isPermaLink="false">http://blog.paulbetts.org/index.php/2006/12/06/porting-apps-to-kde4-part-1/</guid>
		<description><![CDATA[After reading all the awesome things about the new cool things in QT4, especially the graphics stuff, I decided to check it out. And what better way to learn a new technology than to contribute something to the community! So after Emailing the original author and making sure he wasn&#8217;t working on it himself, I [...]]]></description>
			<content:encoded><![CDATA[<p>
After reading all the awesome things about the <a href="http://www.trolltech.com/products/qt/whatsnew">new cool things in QT4</a>, especially the graphics stuff, I decided to check it out. And what better way to learn a new technology than to contribute something to the community! So after Emailing the original author and making sure  he wasn&#8217;t working on it himself, I started to work to port <a href="http://www.methylblue.com/filelight/">Filelight</a>, a handy utility that lets you view your disk usage visually in a way that&#8217;s very easy to get useful information out of. The other thing that is exciting about KDE4 is apps &#8220;by default&#8221; work with Windows too, so in the near future we&#8217;ll see a flood of awesome new open source programs for Windows.
</p>
<p>
The first thing you should do when porting a KDE app is get your environment set up. I did this by going to the <a href="http://developer.kde.org/build/trunk.html">building from SVN guide</a> and following the instructions. Some notes:</p>
<ul>
<li>The guide says to create a separate user, but I think that&#8217;s overkill and somewhat annoying. What I did instead was create a script called kde_dev.sh that has the entries that they put into your .bashrc</li>
<li>Ubuntu Edgy (and most other distros) have a version of D-Bus that&#8217;s up to date enough, don&#8217;t bother compiling your own (it&#8217;ll give you massive headaches trying to get it to cooperate with your system&#8217;s D-Bus anyways)</li>
<li>Originally, I tried to use the Ubuntu KDE4 stuff that&#8217;s in Synaptic but unfortunately something&#8217;s glitched with building projects, cmake will always give you weird errors</li>
</ul>
<p>
Next, since Filelight uses Autotools, I could use the handy <a href="http://websvn.kde.org/trunk/KDE/kdesdk/cmake/scripts/">am2cmake</a> script to create all of the CMakeFiles.txt entries automagically. It&#8217;s kind of cheating, but on the other hand, why should I have to look up a bunch of obscure commands unless I have to? I think I can get the Zeitgeist of cmake by reading the generated files. I also had to create a dummy ConfigureChecks.cmake which I&#8217;ll have to redo manually using the configure.ac file
</p>
<p>
After that, I read the <a href="http://doc.trolltech.com/4.0/porting4.html">Qt 4 Porting Guide</a> and proceeded to cheat even <i>more</i> and use the qt3to4 utility to convert most of the code to Qt 4. However, after I get it to build correctly I&#8217;m going to go back and do a proper port, removing all of the old Qt3&#8242;isms.
</p>
<h4>References:</h4>
<ul>
<li><a href="http://doc.trolltech.com/4.0/porting4.html">Qt 4 Porting Guide</a></li>
<li><a href="http://developer.kde.org/build/trunk.html">Building KDE libraries from SVN</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.paulbetts.org/index.php/2006/12/06/porting-apps-to-kde4-part-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

