<?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>Phalanx Blogosphere &#187; Milot Shala</title>
	<atom:link href="http://phalanx.spartansoft.org/author/m-shala/feed/" rel="self" type="application/rss+xml" />
	<link>http://phalanx.spartansoft.org</link>
	<description>Whatever happens, SPARTAN&#039;S code must stand ... Or at least crash responsibly.</description>
	<lastBuildDate>Sat, 02 Jul 2011 05:19:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Meet me at Qt Developer Days 2010</title>
		<link>http://phalanx.spartansoft.org/2010/09/29/meet-me-at-qt-developer-days-2010/</link>
		<comments>http://phalanx.spartansoft.org/2010/09/29/meet-me-at-qt-developer-days-2010/#comments</comments>
		<pubDate>Wed, 29 Sep 2010 14:55:00 +0000</pubDate>
		<dc:creator>Milot Shala</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://phalanx.spartansoft.org/?p=1125</guid>
		<description><![CDATA[It has been a while since my last post! I am writing this to inform you that I will be attending Qt Developer Days 2010 in Munich, if you happen to be there during the days, feel free to ping me for a conversation.]]></description>
			<content:encoded><![CDATA[<p><center><img src="http://developer.qt.nokia.com/uploads/image_upload/blog_banner.png"></img></center></p>
<p>It has been a while since my last post!</p>
<p>I am writing this to inform you that I will be attending Qt Developer Days 2010 in Munich, if you happen to be there during the days, feel free to ping me for a conversation.</p>
]]></content:encoded>
			<wfw:commentRss>http://phalanx.spartansoft.org/2010/09/29/meet-me-at-qt-developer-days-2010/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>KDE SC 4.4 Release Party in Prishtina, Kosovo</title>
		<link>http://phalanx.spartansoft.org/2010/02/02/kde-sc-4-4-release-party-in-prishtina-kosovo/</link>
		<comments>http://phalanx.spartansoft.org/2010/02/02/kde-sc-4-4-release-party-in-prishtina-kosovo/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 08:55:20 +0000</pubDate>
		<dc:creator>Milot Shala</dc:creator>
				<category><![CDATA[KDE]]></category>

		<guid isPermaLink="false">http://phalanx.spartansoft.org/?p=893</guid>
		<description><![CDATA[I proudly announce that we are having a KDE SC 4.4 Release Party in Prishtina, it will be held on 9th of February at 18:00 o&#8217;clock at IDI (Information Development Initiative) Academy offices, here is the map to the location and here is the link to the KDE.org release party list, you are free to [...]]]></description>
			<content:encoded><![CDATA[<p><center><a href="http://www.kde.org/"><img class="aligncenter" title="KDE Logo" src="http://www.perspektive89.com/system/files/images/170px-Kde-logo.jpg" alt="" width="170" height="170" /></a></center></p>
<p>I proudly announce that we are having a KDE SC 4.4 Release Party in Prishtina, it will be held on 9th of February at 18:00 o&#8217;clock at IDI (Information Development Initiative) Academy offices, <a href='http://www.openstreetmap.org/?lat=42.6562468707561&#038;lon=21.1707079410553&#038;zoom=18'>here</a> is the map to the location and  <a href="http://community.kde.org/Promo/ReleaseParties/4.4#Prishtina">here</a> is the link to the KDE.org release party list, you are free to join us.</p>
<p> Let&#8217;s celebrate together this KDE release.</p>
]]></content:encoded>
			<wfw:commentRss>http://phalanx.spartansoft.org/2010/02/02/kde-sc-4-4-release-party-in-prishtina-kosovo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nokia Certified Qt Developer</title>
		<link>http://phalanx.spartansoft.org/2009/12/29/nokia-certified-qt-developer/</link>
		<comments>http://phalanx.spartansoft.org/2009/12/29/nokia-certified-qt-developer/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 13:30:16 +0000</pubDate>
		<dc:creator>Milot Shala</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://phalanx.spartansoft.org/?p=873</guid>
		<description><![CDATA[I am a proud Qt Developer now. Yesterday I earned the title Nokia Certified Qt Developer.]]></description>
			<content:encoded><![CDATA[<p><center><a href="http://phalanx.spartansoft.org/wp-content/uploads/2009/12/Nokia_Certified_Qt_Developer_Logo.jpg"><img class="aligncenter size-full wp-image-874" title="Nokia Certified Qt Developer" src="http://phalanx.spartansoft.org/wp-content/uploads/2009/12/Nokia_Certified_Qt_Developer_Logo.jpg" alt="" width="360" height="93" /></a></center></p>
<p>I am a proud Qt Developer now. Yesterday I earned the title Nokia Certified Qt Developer.</p>
]]></content:encoded>
			<wfw:commentRss>http://phalanx.spartansoft.org/2009/12/29/nokia-certified-qt-developer/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>SFK09 Qt Presentation</title>
		<link>http://phalanx.spartansoft.org/2009/10/05/sfk09-qt-presentation/</link>
		<comments>http://phalanx.spartansoft.org/2009/10/05/sfk09-qt-presentation/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 01:03:57 +0000</pubDate>
		<dc:creator>Milot Shala</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SFK Conference]]></category>

		<guid isPermaLink="false">http://codespartan.org/blog/?p=699</guid>
		<description><![CDATA[At SFK09 (Software Freedom Kosova) Conference held in 29th and 30th of August 2009 in Prishtina, I&#8217;ve had a speech on cross platform software development using C++ and Qt. I was planning to write about my presentation when videos are ready, unfortunately the videos aren&#8217;t finished yet and I decided to write about the Qt [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://phalanx.spartansoft.org/wp-content/uploads/2009/10/flosskqtlove.png" alt="flosskqtlove" title="flosskqtlove" width="525" height="146" class="aligncenter size-full wp-image-725" /></p>
<p>At SFK09 (Software Freedom Kosova) Conference held in 29th and 30th of August 2009 in Prishtina, I&#8217;ve had a speech on cross platform software development using C++ and Qt.</p>
<p>I was planning to write about my presentation when videos are ready, unfortunately the videos aren&#8217;t finished yet and I decided to write about the Qt presentation and publish only the slides, at least for now.</p>
<p>The speech was technical and in Albanian language. I chose Albanian language for my speech because there are several speeches regarding Qt that are in English and everyone has access for watching them, <a href="http://labs.trolltech.com/blogs/2009/09/05/recorded-talks-from-the-linuxtag-2009/" target="_blank">here</a> you can find three recorded videos from Qt engineers at LinuxTAG.</p>
<p>After the room was filled with attendants, I asked two questions, first: &#8220;how many programmers are in this room?&#8221; and plenty of hands were raised right after my question, second: &#8220;how many of you use .NET Framework in your daily basis for solving problems&#8221; again, almost all programmers in the room was using it.</p>
<p>During the presentation I was more focused on the advantages of using Qt with open source compilers over .NET with real-world facts.</p>
<p>But I still keep using this motto: <b>Right tool for the right job</b></p>
<p><b><i>Logos for the banner are</i></b>:<br />
<i><br />
All Qt logos are © 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide. Taken from <a href="http://qt.nokia.com/about/logos-for-download">Qt Software website</a></p>
<p>Flossk logo is taken from <a href="http://flossk.tuxfamily.org/foswiki/bin/view.pl">Flossk Wiki</a></p>
<p>Heart icon is part of Tango Icon Library and it is taken from their <a href="http://tango.freedesktop.org/Tango_Icon_Library">official website</a><br />
</i></p>
<p>Qt SFK09 Presentation Slides:</p>
<p><iframe src="http://docs.google.com/present/embed?id=dc7qpgnt_152dtktrvcz&#038;hl=en" frameborder="0" width="410" height="342"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://phalanx.spartansoft.org/2009/10/05/sfk09-qt-presentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a translucent QWidget</title>
		<link>http://phalanx.spartansoft.org/2009/09/28/creating-a-translucent-qwidget/</link>
		<comments>http://phalanx.spartansoft.org/2009/09/28/creating-a-translucent-qwidget/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 21:36:45 +0000</pubDate>
		<dc:creator>Milot Shala</dc:creator>
				<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://codespartan.org/blog/?p=615</guid>
		<description><![CDATA[In my earlier post, I mentioned writing my personal video player so I wrote it and I&#8217;m working on it whenever I have time. There are several cool video players out there with great user experience and one of them is VLC which has an awesome OSD (On Screen Display), for long I wanted this [...]]]></description>
			<content:encoded><![CDATA[<p>In my earlier <a href="http://codespartan.org/blog/2009/02/subclassing-phononvideoplayer-for-personalization/">post</a>, I mentioned writing my personal video player so I wrote it and I&#8217;m working on it whenever I have time.</p>
<p>There are several cool video players out there with great user experience and one of them is VLC which has an awesome <a href="http://blog.codefront.net/wp-content/uploads/2006/12/vlc-controller-panel-black-lagoon-levy.png" target="_blank">OSD (On Screen Display)</a>, for long I wanted this feature on my player.</p>
<p>This blog post is a step by step guide on how to create a rectangular semi-transparent widget that looks similar to VLC&#8217;s OSD.</p>
<p><b><i>Note: Result in the end is not exactly as seen in VLC screenshot above, but the widget can be adjusted more to look like it, and when a video is playing in full screen, the widget will look prettier as well.</b></i></p>
<p>Semi transparent widgets can be created using Qt&#8217;s backing store feature introduced in Qt 4.1. For more information on <u>Transparent Backgrounds in Qt</u> read <a href="http://doc.trolltech.com/qq/qq16-background.html" target="_blank">this article</a>.</p>
<p>For implementing a custom widget we start by inheriting QWidget class as shown in Listing 1.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">class</span> CoolWidget <span style="color: #008080;">:</span> <span style="color: #0000ff;">public</span> QWidget
<span style="color: #008000;">&#123;</span>
<span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
    CoolWidget<span style="color: #008000;">&#40;</span>QWidget <span style="color: #000040;">*</span>parent <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">protected</span><span style="color: #008080;">:</span>
    <span style="color: #0000ff;">void</span> paintEvent<span style="color: #008000;">&#40;</span>QPaintEvent <span style="color: #000040;">*</span>pnt<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">void</span> mouseMoveEvent<span style="color: #008000;">&#40;</span>QMouseEvent <span style="color: #000040;">*</span>evt<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">void</span> mousePressEvent<span style="color: #008000;">&#40;</span>QMouseEvent <span style="color: #000040;">*</span>evt<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">private</span><span style="color: #008080;">:</span>
    QPoint dragging_position<span style="color: #008080;">;</span>
    QColor current_color<span style="color: #008080;">;</span>
    QPushButton <span style="color: #000040;">*</span>cool_wdg_button<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">5</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p><i>Listing 1.</i></p>
<p>In CoolWidget class, mouseMoveEvent, mousePressEvent and paintEvent virtual members should be overridden in order to have implementation of specific features of this custom widget, below is the explanation of use for each virtual member:</p>
<p><b>mouseMoveEvent</b> is used to move the widget.<br />
<b>mousePressEvent</b> is used to get the QPoint where mouse position started dragging the widget.<br />
<b>paintEvent</b> is used to paint the widget in our own way (to achieve our purpose of creating rectangular semi-transparent widget).</p>
<p>In paintEvent, QPainter and QPen classes are instantiated. QPainter and QPen classes are used for painting and drawing rectangular borders around the widget. After instantiating QPen, it&#8217;s width and styles are set. In CoolWidget&#8217;s case SolidLine <a href="http://doc.trolltech.com/4.5/qpen.html#setStyle">pen style</a> is used with RoundJoin as <a href="http://doc.trolltech.com/4.5/qpen.html#setJoinStyle">join style</a> and SquareCap as <a href="http://doc.trolltech.com/4.5/qpen.html#setCapStyle">cap style</a>.</p>
<p>After adjusting QPen, alpha value of QColor class instantiated as <b>current_color</b> (See Listing 1) must be set to 100 via <a href="http://doc.trolltech.com/4.5/qcolor.html#setAlpha">QColor::setAlpha</a> method, then use QPainter class&#8217; <a href="http://doc.trolltech.com/4.5/qpainter.html#fillRect-6">fillRect</a> method by passing <a href="http://doc.trolltech.com/4.5/qwidget.html#rect-prop">rect()</a> and the <b>current_color</b> as parameters, then CoolWidget will get a semi-transparent background. In the constructor of CoolWidget&#8217;s <b>current_color</b> is set to <a href="http://doc.trolltech.com/4.5/qt.html#GlobalColor-enum">Qt::black</a>. See Listing 5.</p>
<p>We pass QPen to <a href="http://doc.trolltech.com/4.5/qpainter.html#setPen">QPainter::setPen()</a> and draw the rectangle using <a href="http://doc.trolltech.com/4.5/qwidget.html#rect-prop">rect()</a> method.</p>
<p>Implementation of <b>paintEvent</b> is shown in Listing 2.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">void</span> CoolWidget<span style="color: #008080;">::</span><span style="color: #007788;">paintEvent</span><span style="color: #008000;">&#40;</span>QPaintEvent <span style="color: #000040;">*</span>pnt<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    QPainter painter<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">this</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    QPen pen<span style="color: #008080;">;</span>
    pen.<span style="color: #007788;">setWidth</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">10</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    pen.<span style="color: #007788;">setStyle</span><span style="color: #008000;">&#40;</span>Qt<span style="color: #008080;">::</span><span style="color: #007788;">SolidLine</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    pen.<span style="color: #007788;">setJoinStyle</span><span style="color: #008000;">&#40;</span>Qt<span style="color: #008080;">::</span><span style="color: #007788;">RoundJoin</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    pen.<span style="color: #007788;">setCapStyle</span><span style="color: #008000;">&#40;</span>Qt<span style="color: #008080;">::</span><span style="color: #007788;">SquareCap</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    current_color.<span style="color: #007788;">setAlpha</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">100</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    painter.<span style="color: #007788;">fillRect</span><span style="color: #008000;">&#40;</span>rect<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, current_color<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    painter.<span style="color: #007788;">setPen</span><span style="color: #008000;">&#40;</span>pen<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    painter.<span style="color: #007788;">drawRect</span><span style="color: #008000;">&#40;</span>rect<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><i>Listing 2.</i></p>
<p><b>mousePressEvent</b> is about giving dragging_position a value, which is the subtraction of global position with top left corner of widget&#8217;s frame geometry as shown in Listing 3.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">void</span> CoolWidget<span style="color: #008080;">::</span><span style="color: #007788;">mousePressEvent</span><span style="color: #008000;">&#40;</span>QMouseEvent <span style="color: #000040;">*</span>evt<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>evt<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>button<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">==</span> Qt<span style="color: #008080;">::</span><span style="color: #007788;">LeftButton</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        dragging_position <span style="color: #000080;">=</span> evt<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>globalPos<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">-</span> frameGeometry<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>.<span style="color: #007788;">topLeft</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        evt<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>accept<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><i>Listing 3.</i></p>
<p><b>mouseMoveEvent</b> is about moving the widget. Widget movement is done using <a href="http://doc.trolltech.com/4.5/qwidget.html#pos-prop">move()</a> method, by passing global position QPoint subtracted by dragging_position QPoint as shown in Listing 4.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">void</span> CoolWidget<span style="color: #008080;">::</span><span style="color: #007788;">mouseMoveEvent</span><span style="color: #008000;">&#40;</span>QMouseEvent <span style="color: #000040;">*</span>evt<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>evt<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>buttons<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">==</span> Qt<span style="color: #008080;">::</span><span style="color: #007788;">LeftButton</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        move<span style="color: #008000;">&#40;</span>evt<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>globalPos<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">-</span> dragging_position<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        evt<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>accept<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><i>Listing 4.</i></p>
<p>In constructor the widget is resized to 300&#215;300, current_color is set to black and 5 QPushButtons are created as shown in Listing 5.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">CoolWidget<span style="color: #008080;">::</span><span style="color: #007788;">CoolWidget</span><span style="color: #008000;">&#40;</span>QWidget <span style="color: #000040;">*</span>parent<span style="color: #008000;">&#41;</span>
        <span style="color: #008080;">:</span> QWidget<span style="color: #008000;">&#40;</span>parent<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    current_color <span style="color: #000080;">=</span> Qt<span style="color: #008080;">::</span><span style="color: #007788;">black</span><span style="color: #008080;">;</span>
&nbsp;
    resize<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">300</span>, <span style="color: #0000dd;">300</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i <span style="color: #000080;">&lt;</span> <span style="color: #0000dd;">5</span><span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
        cool_wdg_button<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> QPushButton<span style="color: #008000;">&#40;</span>QString<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;Cool Button %1&quot;</span><span style="color: #008000;">&#41;</span>.<span style="color: #007788;">arg</span><span style="color: #008000;">&#40;</span>i<span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">this</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        cool_wdg_button<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>move<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">10</span>, i <span style="color: #000040;">*</span> <span style="color: #0000dd;">40</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Widget is used with the following snippet:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">CoolWidget <span style="color: #000040;">*</span>coolwdg <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> CoolWidget<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">this</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>And CoolWidget in action:</p>
<p><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='560' height='345'><param name='movie' value='http://screenr.com/Content/assets/screenr_0817090731.swf' /><param name='flashvars' value='i=15070' /><param name='allowFullScreen' value='true' /><embed src='http://screenr.com/Content/assets/screenr_0817090731.swf' flashvars='i=15070' allowFullScreen='true' width='560' height='345' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object></p>
<p>If you find this post useful or have questions regarding the topic, don&#8217;t hesitate to either to leave a comment or write me an email at: milot.shala [at] gmail [dot] com</p>
]]></content:encoded>
			<wfw:commentRss>http://phalanx.spartansoft.org/2009/09/28/creating-a-translucent-qwidget/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>First International Free Software Conference in Kosova</title>
		<link>http://phalanx.spartansoft.org/2009/08/27/first-international-free-software-conference-in-kosova/</link>
		<comments>http://phalanx.spartansoft.org/2009/08/27/first-international-free-software-conference-in-kosova/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 09:01:08 +0000</pubDate>
		<dc:creator>Milot Shala</dc:creator>
				<category><![CDATA[SFK Conference]]></category>

		<guid isPermaLink="false">http://codespartan.org/blog/?p=579</guid>
		<description><![CDATA[First international free software conference in Prishtina, Republic of Kosova is on 29th and 30th of August. Conference  is organized by the local open source community called FLOSSK (Free Libre Open Source Software KOSOVA)  and University of Prishtina, people from two sides were working together to bring the conference to the masses. In 24 August [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.kosovasoftwarefreedom.org/" target="_blank"><img class="aligncenter" title="FLOSSK Logo" src="http://farm4.static.flickr.com/3588/3553024365_c1ccc0ecfb.jpg?v=0" alt="" /></a></p>
<p>First international free software conference in Prishtina, Republic of Kosova is on 29th and 30th of August. Conference  is organized by the local open source community called FLOSSK (Free Libre Open Source Software KOSOVA)  and University of Prishtina, people from two sides were working together to bring the conference to the masses.</p>
<p>In 24 August 2004 a local linux users group called AlbaLINUX (<a href="http://www.albalinux.org" target="_blank">www.albalinux.org</a>) organized a small conference for software freedom day, in which I was one of the helpers and speakers at the conference, but we had very small place for the presentation and it was very modest one, at that time we gave Linux CDs and software freedom day t-shirts for free. So in other hands this was just a start of activities from the local open source software users.</p>
<p>In August 2008 I was in contact with James Mike DuPont and he informed me that he started to work for a bigger conference and that is where all begun. After one year after I started helping I am happy that finally we made it with both help of FLOSSK and University of Prishtina and other young hacker volunteers.</p>
<p>I will be speaking for the conference on the topic of programming in C++ using Qt framework, for which I am very happy because I want to spread Qt programming in Kosova and see more and more local developers using such a powerful framework. I will be publishing slides online and I will try to record the whole speech and publish that online too under the creative commons license.</p>
<p>For this conference we have a great keynotes which are listed below:</p>
<p><span style="font-weight: bold; font-style: italic;">Giuseppe Maxia</span><a name="GuiseppeMaxia"></a> is the MySQL Community Manager.<br />
<span style="font-weight: bold; font-style: italic;">Daniel Carchidi</span><a name="DanielCarchidi"></a> is Publication Director at MIT OpenCourseWare.<br />
<span style="font-weight: bold; font-style: italic;">Flavia Marzano<a name="FlaviaMarzano"></a></span> is a Computer scientist. She is a member of the Italian Open Source committee.<br />
<span style="font-weight: bold; font-style: italic;">Brian King </span>is President of the Mozdev Community Organization.</p>
<p>More information about schedule, other speakers and registration you can find more at the conference website at <a href="http://www.kosovasoftwarefreedom.org/" target="_blank">http://www.kosovasoftwarefreedom.org/</a></p>
<p>I am inviting all of you that are reading this post to come and join us to mark this special weekend.</p>
]]></content:encoded>
			<wfw:commentRss>http://phalanx.spartansoft.org/2009/08/27/first-international-free-software-conference-in-kosova/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Shorten your URLs using Qt</title>
		<link>http://phalanx.spartansoft.org/2009/07/30/shorten-your-urls-using-qt/</link>
		<comments>http://phalanx.spartansoft.org/2009/07/30/shorten-your-urls-using-qt/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 08:04:54 +0000</pubDate>
		<dc:creator>Milot Shala</dc:creator>
				<category><![CDATA[CPP]]></category>
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://codespartan.org/blog/?p=479</guid>
		<description><![CDATA[In today&#8217;s micro-blogging shortening URLs is something necessary because of the character limit on the messages, for example Twitter has the message limit of 140 characters (including spaces), while Facebook has the limit of 160 characters (including spaces), for this reason there are several providers that offer URL shortening services which of course they provide [...]]]></description>
			<content:encoded><![CDATA[<p>In today&#8217;s micro-blogging shortening URLs is something necessary because of the character limit on the messages, for example <a href="http://twitter.com">Twitter</a> has the message limit of 140 characters (including spaces), while <a href="http://facebook.com">Facebook</a> has the limit of 160 characters (including spaces), for this reason there are several providers that offer URL shortening services which of course they provide web service APIs that allow us programmers to create  fun clients around them.</p>
<p>Recently I have seen an <a href="http://arstechnica.com/open-source/guides/2009/07/howto-building-textbox-url-shortener-with-pygtk.ars">arstechnica article</a>  describing how to shorten URLs using PyGTK+ with <a href="http://is.gd/">http://is.gd/</a> service.</p>
<p>I really liked the post and here I will explain how to do something like that but instead of using PyGTK+ I will be using Qt and C++ and instead of <a href="http://is.gd/">http://is.gd/</a> I will be using my favorite service for shortening URLs, <a href="http://tinyurl.com">tinyurl.com</a>.</p>
<p>First of all we will start by creating slots in which we will connect to the corresponding signals to. In our case we will be creating two slots, one to connect with the QPushButton clicked signal, and second to connect with the QHttp&#8217;s done(bool) signal to handle the response, then we declare a private QHttp member which will be sending post requests to the tinyurl&#8217;s service:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">private</span> slots<span style="color: #008080;">:</span>
    <span style="color: #0000ff;">void</span> responseFromTinyUrl<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">void</span> shortenUrlClicked<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">private</span><span style="color: #008080;">:</span>
    QHttp http<span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>In the above code snippet I&#8217;ve written the main parts of a header that I will handle in this blog post.</p>
<p>Now back to our source file, in the constructor I will set the host of the QHttp instance to www.tinyurl.com, which is very simple, just have to call the setHost(QString) function,</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">http.<span style="color: #007788;">setHost</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;www.tinyurl.com&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>after setting the host on the constructor we connect our slots with corresponding signals, suppose that I already have a QPushButton object instance called buttonShorten,</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">connect<span style="color: #008000;">&#40;</span>buttonShorten, SIGNAL<span style="color: #008000;">&#40;</span>clicked<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">this</span>, SLOT<span style="color: #008000;">&#40;</span>shortenUrlClicked<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
connect<span style="color: #008000;">&#40;</span><span style="color: #000040;">&amp;</span>http, SIGNAL<span style="color: #008000;">&#40;</span>done<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">bool</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">this</span>, SLOT<span style="color: #008000;">&#40;</span>responseFromTinyUrl<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>the implementation of the shortenUrlClicked slot is done by calling a post(QString, QByteArray) function to send a post request to the server,</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">void</span> ShortenURLDialog<span style="color: #008080;">::</span><span style="color: #007788;">shortenUrlClicked</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
     http.<span style="color: #007788;">post</span><span style="color: #008000;">&#40;</span>QString<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;api-create.php?url=%1&quot;</span><span style="color: #008000;">&#41;</span>.<span style="color: #007788;">arg</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;very long url here&quot;</span><span style="color: #008000;">&#41;</span>, QByteArray<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>then we will handle the response that is the actual shortened URL from tinyurl.com service on the responseFromTinyUrl() function, in which we call the readAll() function to read the whole response because there will be only the shortened url string which we will display it on a simple QMessageBox,</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">void</span> ShortURLDialog<span style="color: #008080;">::</span><span style="color: #007788;">responseFromTinyUrl</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    QMessageBox<span style="color: #008080;">::</span><span style="color: #007788;">information</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">this</span>, <span style="color: #FF0000;">&quot;Shortened URL&quot;</span>, http.<span style="color: #007788;">readAll</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><b>Conclusion</b><br />
You can use any other service like tinyurl.com (for example is.gd), just replace the host and post functions to the service&#8217;s API. You can see an example of how to update the Twitter status using the same method explained in <a href="http://codespartan.org/blog/2009/05/behind-twithor-updating-twitter-status-message-using-qt/">my earlier post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://phalanx.spartansoft.org/2009/07/30/shorten-your-urls-using-qt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It&#039;s a plane, It&#039;s a train&#8230; It&#039;s a C++ elaborated type specifier!</title>
		<link>http://phalanx.spartansoft.org/2009/06/15/its-a-plane-its-a-train-its-a-c-elaborated-type-specifier/</link>
		<comments>http://phalanx.spartansoft.org/2009/06/15/its-a-plane-its-a-train-its-a-c-elaborated-type-specifier/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 22:06:34 +0000</pubDate>
		<dc:creator>Milot Shala</dc:creator>
				<category><![CDATA[CPP]]></category>

		<guid isPermaLink="false">http://codespartan.org/blog/?p=424</guid>
		<description><![CDATA[As we programmers know C++ is very expressive and powerful programming language, sometimes you feel that you have your compiler in your hands and you must teach it how to behave like a little child, and yes, this is true. These days I am hacking on some random projects in my spare time and I [...]]]></description>
			<content:encoded><![CDATA[<p><center><img src="http://www.scenicreflections.com/ithumbs/superman_returns_logo_wallpaper_215.jpg"/></center><br />
<br />
As we programmers know C++ is very expressive and powerful programming language, sometimes you feel that you have your compiler in your hands and you must teach it how to behave like a little child, and yes, this is true.<br />
<br />
These days I am hacking on some random projects in my spare time and I came up with something that confused me, some function names are identical with some class names and sometimes C++ compiler allows that, but how this can be achievable?<br />
<br />
C++ use elaborated type specifiers to tell the compiler explicitly to treat a class as a class, and this will be described technically in the following paragraphs.<br />
<br />
I have created a situation using the Factory pattern (see: <a href="http://www.oodesign.com/factory-pattern.html">Factory Pattern</a>). In our case you have a Child class and when some piece of code needs an object instance of Child class, the Factory class creates a Child object instance and returns it via createChild() method.<br />
<br />
Here is the implementation of Child class, basically it does nothing just prints out a message:<br />
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">class</span> Child
<span style="color: #008000;">&#123;</span>
<span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
  Child<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
  <span style="color: #0000ff;">void</span> printGreetingMessage<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
Child<span style="color: #008080;">::</span><span style="color: #007788;">Child</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> Child<span style="color: #008080;">::</span><span style="color: #007788;">printGreetingMessage</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Greetings from a Child class<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>
To achieve the goal you must have a Factory class which has two methods one for creating a Child object and second for destroying it, the function for creating the object returns a pointer to Child class.<br />
<br />
Before continuing to the Factory class implementation, suppose that you have some header file included in this source file that has a function named Child():<br />
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">inline</span> <span style="color: #0000ff;">void</span> Child<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Greetings from a function with the same name<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>
While you are designing your Factory class you run into compile-time errors telling you that you must be more careful with this one, this is because if try to declare a class in the standard way the compiler cannot identify a class and a function that possess the same name, you must be more specific to the compiler in this situation telling compiler that the following Child class is a class by specifying <strong>class</strong> keyword in front of the class type:<br />
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #666666;">// when creating a Child object</span>
<span style="color: #0000ff;">class</span> Child _child<span style="color: #008080;">;</span>
&nbsp;
<span style="color: #666666;">// when calling Child function</span>
Child<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>
and here is complete code for a Factory class using elaborated type specifier:<br />
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">class</span> Factory
<span style="color: #008000;">&#123;</span>
<span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
  Factory<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
  ~Factory<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
  <span style="color: #0000ff;">class</span> Child<span style="color: #000040;">*</span> createChild<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// return pointer to Child object</span>
  <span style="color: #0000ff;">void</span> destroyChild<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>  <span style="color: #666666;">// destroy created object</span>
&nbsp;
<span style="color: #0000ff;">private</span><span style="color: #008080;">:</span>
  <span style="color: #0000ff;">class</span> Child <span style="color: #000040;">*</span>_child<span style="color: #008080;">;</span> <span style="color: #666666;">// declare pointer to child object</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
Factory<span style="color: #008080;">::</span><span style="color: #007788;">Factory</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
Factory<span style="color: #008080;">::</span>~Factory<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  destroyChild<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">class</span> Child <span style="color: #000040;">*</span>Factory<span style="color: #008080;">::</span><span style="color: #007788;">createChild</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  _child <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> <span style="color: #0000ff;">class</span> Child<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// create instance of a Child class and return it's pointer</span>
  <span style="color: #0000ff;">return</span> _child<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> Factory<span style="color: #008080;">::</span><span style="color: #007788;">destroyChild</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  <span style="color: #0000dd;">delete</span> _child<span style="color: #008080;">;</span> <span style="color: #666666;">// free the mallocs!</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>
Main function using elaborated type specifier for Child class:<br />
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
&nbsp;
  Factory f<span style="color: #008080;">;</span>
  <span style="color: #666666;">// still using elaborated type specifier</span>
  <span style="color: #0000ff;">class</span> Child <span style="color: #000040;">*</span>real_child <span style="color: #000080;">=</span> f.<span style="color: #007788;">createChild</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
  real_child<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>printGreetingMessage<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
  Child<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
  <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>
After compilation output:<br />
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">milot<span style="color: #000000; font-weight: bold;">@</span>lambda:~<span style="color: #000000; font-weight: bold;">/</span>Desktop$ .<span style="color: #000000; font-weight: bold;">/</span>elaborate
Greetings from a class
Greetings from a <span style="color: #000000; font-weight: bold;">function</span> with the same name
milot<span style="color: #000000; font-weight: bold;">@</span>lambda:~<span style="color: #000000; font-weight: bold;">/</span>Desktop$</pre></td></tr></table></div>

<p>After you received this information, don&#8217;t try this in a real project, it may cause headaches and is not recommended to use such construct but you can use it if necessary, as for me, I barely use this construct, but sometimes I find it useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://phalanx.spartansoft.org/2009/06/15/its-a-plane-its-a-train-its-a-c-elaborated-type-specifier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Behind Twithor &#8211; Updating Twitter status message using Qt</title>
		<link>http://phalanx.spartansoft.org/2009/05/22/behind-twithor-updating-twitter-status-message-using-qt/</link>
		<comments>http://phalanx.spartansoft.org/2009/05/22/behind-twithor-updating-twitter-status-message-using-qt/#comments</comments>
		<pubDate>Fri, 22 May 2009 12:03:17 +0000</pubDate>
		<dc:creator>Milot Shala</dc:creator>
				<category><![CDATA[CPP]]></category>
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://codespartan.org/blog/?p=396</guid>
		<description><![CDATA[In my earlier post, I&#8217;ve introduced to you Twithor, which is a small application that allow users to update their status message on twitter. In this post I will explain Twithor under the hood, how to implement this feature to your application. For this kind of problem, we will be using QHttp class which provides [...]]]></description>
			<content:encoded><![CDATA[<p>In my earlier post, I&#8217;ve introduced to you Twithor, which is a small application that allow users to update their status message on twitter. In this post I will explain Twithor under the hood, how to implement this feature to your application.</p>
<p>For this kind of problem, we will be using QHttp class which provides the HTTP Request functionality, and we will be using Twitter API to send an http request via POST method.</p>
<p>Now we need to create an instance of QHttp class:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">QHttp <span style="color: #000040;">*</span>twitter_http_updater <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> QHttp<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>QHttp class provides methods for sending http request to the server, but first we need to tell in which host to send the message, we will need to tell the username and password for the message because the Twitter system is not that intelligent to know that you are sending a message without knowing your credentials and in the end as I mentioned above we need to use twitter api to send the message.</p>
<p><em>Code means a thousands words</em></p>
<p>Signatures of the functions that we will be using are:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #666666;">// for setting the hostname</span>
QHttp<span style="color: #008080;">::</span><span style="color: #007788;">setHost</span> <span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">const</span> QString <span style="color: #000040;">&amp;</span> hostName, quint16 port <span style="color: #000080;">=</span> <span style="color: #0000dd;">80</span> <span style="color: #008000;">&#41;</span>
&nbsp;
<span style="color: #666666;">// for setting the username and password</span>
QHttp<span style="color: #008080;">::</span><span style="color: #007788;">setUser</span> <span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">const</span> QString <span style="color: #000040;">&amp;</span> userName, <span style="color: #0000ff;">const</span> QString <span style="color: #000040;">&amp;</span> password <span style="color: #000080;">=</span> QString<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span>
&nbsp;
<span style="color: #666666;">// for sending the request to the server</span>
QHttp<span style="color: #008080;">::</span><span style="color: #007788;">post</span> <span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">const</span> QString <span style="color: #000040;">&amp;</span> path, <span style="color: #0000ff;">const</span> QByteArray <span style="color: #000040;">&amp;</span> data, QIODevice <span style="color: #000040;">*</span> to <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #008000;">&#41;</span></pre></td></tr></table></div>

<p>As seen in the code above QIODevice optional value of the parameter is set to 0 and if we don&#8217;t use that parameter it will be 0, but in the other hand QByteArray reference variable need to be passed and we pass the empty QByteArray() because we are using only path parameter to send the data with the request as seen in the code below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">twitter_http_updater<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>setHost<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;www.twitter.com&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
twitter_http_updater<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>setUser<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;yourusername&quot;</span>, <span style="color: #FF0000;">&quot;yourpassword&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
twitter_http_updater<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>post<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;/statuses/update.xml?status=mybeautifulmessage&quot;</span>, QByteArray<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>One more thing for the end, in Twithor I am handling <strong>done</strong> signal by a slot. Done signal is emitted when the request was sent and the response is received in other words when the communication is finished between the host and your client, <strong>done</strong> signal has the following signature:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">QHttp<span style="color: #008080;">::</span><span style="color: #007788;">done</span> <span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">bool</span> error <span style="color: #008000;">&#41;</span>   <span style="color: #008000;">&#91;</span><span style="color: #0000ff;">signal</span><span style="color: #008000;">&#93;</span></pre></td></tr></table></div>

<p>I connected this signal to a slot nicely:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">connect<span style="color: #008000;">&#40;</span>twitter_http_updater, SIGNAL<span style="color: #008000;">&#40;</span>done<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">bool</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">this</span>, SLOT<span style="color: #008000;">&#40;</span>updateTwitterStatusFinish<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>And this slot will be fired when the signal is emitted and I&#8217;ve implemented the the slot to tell the user that his or her status is updated, you can see more features by reading the docs <a href="http://doc.trolltech.com/4.5/qhttp.html">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://phalanx.spartansoft.org/2009/05/22/behind-twithor-updating-twitter-status-message-using-qt/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>New Personal Twitter Client</title>
		<link>http://phalanx.spartansoft.org/2009/05/01/new-personal-twitter-client/</link>
		<comments>http://phalanx.spartansoft.org/2009/05/01/new-personal-twitter-client/#comments</comments>
		<pubDate>Fri, 01 May 2009 23:04:05 +0000</pubDate>
		<dc:creator>Milot Shala</dc:creator>
				<category><![CDATA[CPP]]></category>
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://codespartan.org/blog/?p=378</guid>
		<description><![CDATA[I have a Twitter account for some time now but I haven&#8217;t used it much because there were times that I forgot that the service exists and that I have an account there. I&#8217;ve seen several twitter clients out there but I wanted something smoother and smaller to fit in my desktop in order that [...]]]></description>
			<content:encoded><![CDATA[<p>I have a <a href="http://www.twitter.com/">Twitter</a> account for some time now but I haven&#8217;t used it much because there were times that I forgot that the service exists and that I have an account there. I&#8217;ve seen several twitter clients out there but I wanted something smoother and smaller to fit in my desktop in order that I can just leave it there and post whenever I see it. I know that this is very simple one but I wanted to also create something cool with QHttp class so twitter was in my mind and I wrote a simple software to fit my needs for very clean and simple desktop twitter client.</p>
<p>I named it Twithor (after <a href="http://en.wikipedia.org/wiki/Thor_(Marvel_Comics)">Marvel&#8217;s Fictional Character THOR</a>) and it opens in a small window which doesn&#8217;t bother you while working and you can place it on your desktop, but since it is in the early stage of development I am not posting the source code yet because before releasing the source code I must do some code refactoring to avoid WTFs. I will also port it to Windows and of course it will be translated in to my native Albanian language.</p>
<p>Below is screenshot (taken under Linux) that I made and <a href="http://twitter.com/milot/status/1673719477">here</a> is the message posted to twitter.</p>
<p><img class="aligncenter size-full wp-image-379" title="twithor_screenshot" src="http://phalanx.spartansoft.org/wp-content/uploads/2009/05/twithor_screenshot.png" alt="twithor_screenshot" width="471" height="420" /></p>
<p><strong>Update: </strong><em>Ported Twithor to Windows, thanks to Qt framework!</em><strong><br />
</strong></p>
<p><strong><img class="aligncenter size-full wp-image-392" title="twithor_sc" src="http://phalanx.spartansoft.org/wp-content/uploads/2009/05/twithor_sc.png" alt="twithor_sc" width="460" height="388" /><br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://phalanx.spartansoft.org/2009/05/01/new-personal-twitter-client/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

